http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72893

Revision: 72893
Author:   tstarling
Date:     2010-09-13 07:18:10 +0000 (Mon, 13 Sep 2010)

Log Message:
-----------
MFT r71942, r72024, r72120, r72525: supporting changes for PagedTiffHandler 
file verification.

Modified Paths:
--------------
    branches/wmf/1.16wmf4/includes/media/Generic.php
    branches/wmf/1.16wmf4/includes/upload/UploadBase.php

Property Changed:
----------------
    branches/wmf/1.16wmf4/includes/


Property changes on: branches/wmf/1.16wmf4/includes
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes:51646
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381,60970
/trunk/phase3/includes:63549,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,71059,71098
   + /branches/REL1_15/phase3/includes:51646
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381,60970
/trunk/phase3/includes:63549,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,71059,71098,71942,72024,72120,72525

Modified: branches/wmf/1.16wmf4/includes/media/Generic.php
===================================================================
--- branches/wmf/1.16wmf4/includes/media/Generic.php    2010-09-13 06:29:15 UTC 
(rev 72892)
+++ branches/wmf/1.16wmf4/includes/media/Generic.php    2010-09-13 07:18:10 UTC 
(rev 72893)
@@ -273,6 +273,20 @@
        function parserTransformHook( $parser, $file ) {}
 
        /**
+        * File validation hook called on upload.
+        *
+        * If the file at the given local path is not valid, or its MIME type 
does not 
+        * match the handler class, a Status object should be returned 
containing
+        * relevant errors.
+        * 
+        * @param $fileName The local path to the file.
+        * @return Status object
+        */
+       function verifyUpload( $fileName ) {
+               return Status::newGood();
+       }
+
+       /**
         * Check for zero-sized thumbnails. These can be generated when
         * no disk space is available or some other error occurs
         *

Modified: branches/wmf/1.16wmf4/includes/upload/UploadBase.php
===================================================================
--- branches/wmf/1.16wmf4/includes/upload/UploadBase.php        2010-09-13 
06:29:15 UTC (rev 72892)
+++ branches/wmf/1.16wmf4/includes/upload/UploadBase.php        2010-09-13 
07:18:10 UTC (rev 72893)
@@ -279,6 +279,22 @@
                if ( $virus ) {
                        return array( 'uploadvirus', $virus );
                }
+
+               $handler = MediaHandler::getHandler( $mime );
+               if ( $handler ) {
+                       $handlerStatus = $handler->verifyUpload( 
$this->mTempPath );
+                       if ( !$handlerStatus->isOK() ) {
+                               $errors = $handlerStatus->getErrorsArray();
+                               return reset( $errors );
+                       }
+               }
+
+               $status = true;
+               wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) 
);
+               if ( $status !== true ) {
+                       return $status;
+               }
+
                wfDebug( __METHOD__ . ": all clear; passing.\n" );
                return true;
        }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to