X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2Fupload%2FUploadBase.php;h=2419299086f0c5ac2438aa7646cb960d16f8cf72;hb=e6e68618810b828a7de84dfe164e768da8ba90bf;hp=6a6b358aae4aa38eff0ea0258ea41fcd2836f86e;hpb=4169b4f42502ca1956f7a7253b5f54e1901e7821;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 6a6b358aae..2419299086 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -171,6 +171,7 @@ abstract class UploadBase { return null; } + /** @var UploadBase $handler */ $handler = new $className; $handler->initializeFromRequest( $request ); @@ -377,11 +378,12 @@ abstract class UploadBase { } /** - * Verify the mime type. + * Verify the MIME type. * - * @note Only checks that it is not an evil mime. The "does it have - * correct extension given its mime type?" check is in verifyFile. - * @param string $mime Representing the mime + * @note Only checks that it is not an evil MIME. The "does it have + * correct extension given its MIME type?" check is in verifyFile. + * in `verifyFile()` that MIME type and file extension correlate. + * @param string $mime Representing the MIME * @return mixed True if the file is verified, an array otherwise */ protected function verifyMimeType( $mime ) { @@ -396,7 +398,7 @@ abstract class UploadBase { return array( 'filetype-badmime', $mime ); } - # Check IE type + # Check what Internet Explorer would detect $fp = fopen( $this->mTempPath, 'rb' ); $chunk = fread( $fp, 256 ); fclose( $fp ); @@ -487,7 +489,7 @@ abstract class UploadBase { $this->mFileProps = FSFile::getPropsFromPath( $this->mTempPath, $this->mFinalExtension ); - # check mime type, if desired + # check MIME type, if desired $mime = $this->mFileProps['file-mime']; $status = $this->verifyMimeType( $mime ); if ( $status !== true ) { @@ -744,6 +746,8 @@ abstract class UploadBase { ); } wfRunHooks( 'UploadComplete', array( &$this ) ); + + $this->postProcessUpload(); } wfProfileOut( __METHOD__ ); @@ -751,6 +755,26 @@ abstract class UploadBase { return $status; } + /** + * Perform extra steps after a successful upload. + */ + public function postProcessUpload() { + global $wgUploadThumbnailRenderMap; + + $jobs = array(); + + $sizes = $wgUploadThumbnailRenderMap; + rsort( $sizes ); + + foreach ( $sizes as $size ) { + $jobs []= new ThumbnailRenderJob( $this->getLocalFile()->getTitle(), array( + 'transformParams' => array( 'width' => $size ), + ) ); + } + + JobQueueGroup::singleton()->push( $jobs ); + } + /** * Returns the title of the file to be uploaded. Sets mTitleError in case * the name was illegal. @@ -881,7 +905,7 @@ abstract class UploadBase { /** * Return the local file and initializes if necessary. * - * @return LocalFile|null + * @return LocalFile|UploadStashFile|null */ public function getLocalFile() { if ( is_null( $this->mLocalFile ) ) { @@ -995,9 +1019,9 @@ abstract class UploadBase { } /** - * Checks if the mime type of the uploaded file matches the file extension. + * Checks if the MIME type of the uploaded file matches the file extension. * - * @param string $mime The mime type of the uploaded file + * @param string $mime The MIME type of the uploaded file * @param string $extension The filename extension that the file is to be served with * @return bool */ @@ -1050,7 +1074,7 @@ abstract class UploadBase { * positives in some situations. * * @param string $file Pathname to the temporary upload file - * @param string $mime The mime type of the file + * @param string $mime The MIME type of the file * @param string $extension The extension of the file * @return bool True if the file contains something looking like embedded scripts */ @@ -1295,7 +1319,8 @@ abstract class UploadBase { * @param array $attribs * @return bool */ - public function checkSvgScriptCallback( $element, $attribs ) { + public function checkSvgScriptCallback( $element, $attribs, $data = null ) { + list( $namespace, $strippedElement ) = $this->splitXmlNamespace( $element ); // We specifically don't include: @@ -1379,6 +1404,14 @@ abstract class UploadBase { return true; } + # Check