r72893 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72892‎ | r72893 | r72894 >
Date:07:18, 13 September 2010
Author:tstarling
Status:deferred
Tags:
Comment:
MFT r71942, r72024, r72120, r72525: supporting changes for PagedTiffHandler file verification.
Modified paths:
  • /branches/wmf/1.16wmf4/includes (modified) (history)
  • /branches/wmf/1.16wmf4/includes/media/Generic.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/includes/upload/UploadBase.php
@@ -279,6 +279,22 @@
280280 if ( $virus ) {
281281 return array( 'uploadvirus', $virus );
282282 }
 283+
 284+ $handler = MediaHandler::getHandler( $mime );
 285+ if ( $handler ) {
 286+ $handlerStatus = $handler->verifyUpload( $this->mTempPath );
 287+ if ( !$handlerStatus->isOK() ) {
 288+ $errors = $handlerStatus->getErrorsArray();
 289+ return reset( $errors );
 290+ }
 291+ }
 292+
 293+ $status = true;
 294+ wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) );
 295+ if ( $status !== true ) {
 296+ return $status;
 297+ }
 298+
283299 wfDebug( __METHOD__ . ": all clear; passing.\n" );
284300 return true;
285301 }
Index: branches/wmf/1.16wmf4/includes/media/Generic.php
@@ -273,6 +273,20 @@
274274 function parserTransformHook( $parser, $file ) {}
275275
276276 /**
 277+ * File validation hook called on upload.
 278+ *
 279+ * If the file at the given local path is not valid, or its MIME type does not
 280+ * match the handler class, a Status object should be returned containing
 281+ * relevant errors.
 282+ *
 283+ * @param $fileName The local path to the file.
 284+ * @return Status object
 285+ */
 286+ function verifyUpload( $fileName ) {
 287+ return Status::newGood();
 288+ }
 289+
 290+ /**
277291 * Check for zero-sized thumbnails. These can be generated when
278292 * no disk space is available or some other error occurs
279293 *
Property changes on: branches/wmf/1.16wmf4/includes
___________________________________________________________________
Modified: svn:mergeinfo
280294 Merged /trunk/phase3/includes:r71942,72024,72120,72525

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71942interoduced new hoop in Uploadbase::verifyFile, as per comments to r71789daniel12:10, 30 August 2010
r72024introducing Generic::verifyFileHook() to let media handlers do the verificati...daniel14:08, 31 August 2010
r72120Call time pass-by-refdemon17:15, 1 September 2010
r72525Fixes for r72024:...tstarling10:38, 7 September 2010

Status & tagging log