r76341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76340‎ | r76341 | r76342 >
Date:21:07, 8 November 2010
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
Undeprecate UploadForm:BeforeProcessing. Instead only deprecate the code path that would return the user a blank form with no error message.
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1678,10 +1678,13 @@
16791679 $uploadFormTextAfterSummary to inject text (HTML) either before
16801680 or after the editform.
16811681
1682 -'UploadForm:BeforeProcessing': DEPRECATED! at the beginning of processUpload()
 1682+'UploadForm:BeforeProcessing': at the beginning of processUpload()
16831683 $form: UploadForm object
16841684 Lets you poke at member variables like $mUploadDescription before the
16851685 file is saved.
 1686+Do not use this hook to break upload processing. This will return the user to
 1687+a blank form with no error message; use UploadVerification and
 1688+UploadVerifyFile instead
16861689
16871690 'UploadCreateFromRequest': when UploadBase::createFromRequest has been called
16881691 $type: (string) the requested upload type
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -266,7 +266,6 @@
267267 $error = '';
268268 if( !wfRunHooks( 'UploadVerification',
269269 array( $this->mDestName, $this->mTempPath, &$error ) ) ) {
270 - // @fixme This status needs another name...
271270 return array( 'status' => self::HOOK_ABORTED, 'error' => $error );
272271 }
273272
Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -425,12 +425,13 @@
426426 return;
427427 }
428428
429 - // Deprecated backwards compatibility hook
430429 if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) {
431430 wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file.\n" );
432 - // Return without notifying the user of an error. This sucks, but
433 - // this was the previous behaviour as well, and as this hook is
434 - // deprecated we're not going to do anything about it.
 431+ // This code path is deprecated. If you want to break upload processing
 432+ // do so by hooking into the appropriate hooks in UploadBase::verifyUpload
 433+ // and UploadBase::verifyFile.
 434+ // If you use this hook to break uploading, the user will be returned
 435+ // an empty form with no error message whatsoever.
435436 return;
436437 }
437438

Comments

#Comment by Brion VIBBER (talk | contribs)   03:24, 9 November 2010

Any reason not to have this case behave as though verifyUpload had returned a HOOK_ABORTED error with a generic message here?

#Comment by Bryan (talk | contribs)   19:58, 11 November 2010

Could be done.

#Comment by MarkAHershberger (talk | contribs)   18:56, 11 January 2011

marking OK since it is just comments and Brion already suggested some changes.

Status & tagging log