Index: branches/wmf/1.16wmf4/includes/upload/UploadBase.php |
— | — | @@ -279,6 +279,22 @@ |
280 | 280 | if ( $virus ) { |
281 | 281 | return array( 'uploadvirus', $virus ); |
282 | 282 | } |
| 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 | + |
283 | 299 | wfDebug( __METHOD__ . ": all clear; passing.\n" ); |
284 | 300 | return true; |
285 | 301 | } |
Index: branches/wmf/1.16wmf4/includes/media/Generic.php |
— | — | @@ -273,6 +273,20 @@ |
274 | 274 | function parserTransformHook( $parser, $file ) {} |
275 | 275 | |
276 | 276 | /** |
| 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 | + /** |
277 | 291 | * Check for zero-sized thumbnails. These can be generated when |
278 | 292 | * no disk space is available or some other error occurs |
279 | 293 | * |
Property changes on: branches/wmf/1.16wmf4/includes |
___________________________________________________________________ |
Modified: svn:mergeinfo |
280 | 294 | Merged /trunk/phase3/includes:r71942,72024,72120,72525 |