r71942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71941‎ | r71942 | r71943 >
Date:12:10, 30 August 2010
Author:daniel
Status:resolved (Comments)
Tags:
Comment:
interoduced new hoop in Uploadbase::verifyFile, as per comments to r71789
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1671,7 +1671,8 @@
16721672 added to the descriptor
16731673 $descriptor: (array) the HTMLForm descriptor
16741674
1675 -'UploadVerification': additional chances to reject an uploaded file
 1675+'UploadVerification': additional chances to reject an uploaded file. Consider
 1676+ using UploadVerifyFile instead.
16761677 string $saveName: destination file name
16771678 string $tempName: filesystem path to the temporary file for checks
16781679 string &$error: output: message key for message to show if upload canceled
@@ -1679,6 +1680,16 @@
16801681 is the message key and the remaining elements are used as parameters to
16811682 the message.
16821683
 1684+'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred
 1685+ in most cases over UploadVerification.
 1686+object $upload: an instance of UploadBase, with all info about the upload
 1687+object $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers
 1688+ will typically only apply for specific mime types.
 1689+object &$error: output: true if the file is valid. Otherwise, and indexed array
 1690+ representing the problem with the file, where the first element
 1691+ is the message key and the remaining elements are used as parameters to
 1692+ the message.
 1693+
16831694 'UploadComplete': Upon completion of a file upload
16841695 $uploadBase: UploadBase (or subclass) object. File can be accessed by
16851696 $uploadBase->getLocalFile().
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -371,6 +371,12 @@
372372 if ( $virus ) {
373373 return array( 'uploadvirus', $virus );
374374 }
 375+
 376+ wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) );
 377+ if ( $status !== true ) {
 378+ return $status;
 379+ }
 380+
375381 wfDebug( __METHOD__ . ": all clear; passing.\n" );
376382 return true;
377383 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r71943use new UploadVerifyFile hook, introduced in r71942daniel12:18, 30 August 2010
r72020Followup r71942. Documentation fix, the mime passed is a string, not an object.hartman11:01, 31 August 2010
r72893MFT r71942, r72024, r72120, r72525: supporting changes for PagedTiffHandler f...tstarling07:18, 13 September 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71789abort PagedTiffHandler::check if the file in question isn't a tiff filedaniel12:43, 27 August 2010

Comments

#Comment by Tim Starling (talk | contribs)   09:11, 7 September 2010

Why is it a hook and not a MediaHandler method?

#Comment by Duesentrieb (talk | contribs)   09:13, 7 September 2010

see r72024 and r72025

Status & tagging log