r72024 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72023‎ | r72024 | r72025 >
Date:14:08, 31 August 2010
Author:daniel
Status:resolved
Tags:
Comment:
introducing Generic::verifyFileHook() to let media handlers do the verification on upload. triggered from UploadBase:verifyFile, like the UploadVerifyFile hook.
Modified paths:
  • /trunk/phase3/includes/media/Generic.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadBase.php
@@ -371,6 +371,14 @@
372372 return array( 'uploadvirus', $virus );
373373 }
374374
 375+ $handler = MediaHandler::getHandler( $mime );
 376+ if ( $handler ) {
 377+ $handler->verifyFileHook( $this, $mime, &$status );
 378+ if ( $status !== true ) {
 379+ return $status;
 380+ }
 381+ }
 382+
375383 wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) );
376384 if ( $status !== true ) {
377385 return $status;
Index: trunk/phase3/includes/media/Generic.php
@@ -274,6 +274,21 @@
275275 function parserTransformHook( $parser, $file ) {}
276276
277277 /**
 278+ * File validation hook; Called by UploadBase::verifyFile, exactly like UploadVerifyFile hooks.
 279+ * If the file represented by the $upload object is not valid, $error should be set to an array
 280+ * in which the first item is the name of a system message describing the problem, and any
 281+ * remaining items are parameters for that message. In that case, verifyFileHook should return false.
 282+ *
 283+ * @param $upload An instance of UploadBase, representing a freshly uploaded file
 284+ * @param $mime The mime type of the uploaded file
 285+ * @param $error (output) set to an array describing the problem, if there is one. If the file is OK, this should not be modified.
 286+ * @return true if the file is OK, false otherwise
 287+ */
 288+ function verifyFileHook( $upload, $mime, &$error ) {
 289+ return true;
 290+ }
 291+
 292+ /**
278293 * Check for zero-sized thumbnails. These can be generated when
279294 * no disk space is available or some other error occurs
280295 *

Follow-up revisions

RevisionCommit summaryAuthorDate
r72025use file verification via MediaHandler interface. requires r72024 in core.daniel14:09, 31 August 2010
r72525Fixes for r72024:...tstarling10:38, 7 September 2010
r72893MFT r71942, r72024, r72120, r72525: supporting changes for PagedTiffHandler f...tstarling07:18, 13 September 2010

Status & tagging log