X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fupload%2FUploadBase.php;h=9f534d2eb69e3b21c2063f0ea38bfa78173fad9d;hb=7e0d148f5790711f992f96f76a1e78e61d711db9;hp=5320673f0e3542063b282dc790245add4ac1909d;hpb=1cdd4682ed43ffe4d95597e54836189ca974404b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 5320673f0e..9f534d2eb6 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -774,27 +774,6 @@ abstract class UploadBase { * @since 1.25 */ public function postProcessUpload() { - global $wgUploadThumbnailRenderMap; - - $jobs = []; - - $sizes = $wgUploadThumbnailRenderMap; - rsort( $sizes ); - - $file = $this->getLocalFile(); - - foreach ( $sizes as $size ) { - if ( $file->isVectorized() || $file->getWidth() > $size ) { - $jobs[] = new ThumbnailRenderJob( - $file->getTitle(), - [ 'transformParams' => [ 'width' => $size ] ] - ); - } - } - - if ( $jobs ) { - JobQueueGroup::singleton()->push( $jobs ); - } } /** @@ -944,6 +923,33 @@ abstract class UploadBase { return $this->mLocalFile; } + /** + * Like stashFile(), but respects extensions' wishes to prevent the stashing. + * + * Upload stash exceptions are also caught and converted to an error status. + * + * @since 1.28 + * @param User $user + * @return Status If successful, value is an UploadStashFile instance + */ + public function tryStashFile( User $user ) { + $props = $this->mFileProps; + $error = null; + Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] ); + if ( $error ) { + if ( !is_array( $error ) ) { + $error = [ $error ]; + } + return call_user_func_array( 'Status::newFatal', $error ); + } + try { + $file = $this->doStashFile( $user ); + return Status::newGood( $file ); + } catch ( UploadStashException $e ) { + return Status::newFatal( 'uploadstash-exception', get_class( $e ), $e->getMessage() ); + } + } + /** * If the user does not supply all necessary information in the first upload * form submission (either by accident or by design) then we may want to @@ -956,10 +962,24 @@ abstract class UploadBase { * which can be passed through a form or API request to find this stashed * file again. * + * @deprecated since 1.28 Use tryStashFile() instead * @param User $user * @return UploadStashFile Stashed file + * @throws UploadStashBadPathException + * @throws UploadStashFileException + * @throws UploadStashNotLoggedInException */ public function stashFile( User $user = null ) { + return $this->doStashFile( $user ); + } + + /** + * Implementation for stashFile() and tryStashFile(). + * + * @param User $user + * @return UploadStashFile Stashed file + */ + protected function doStashFile( User $user = null ) { $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $user ); $file = $stash->stashFile( $this->mTempPath, $this->getSourceType() ); $this->mLocalFile = $file; @@ -976,7 +996,7 @@ abstract class UploadBase { */ public function stashFileGetKey() { wfDeprecated( __METHOD__, '1.28' ); - return $this->stashFile()->getFileKey(); + return $this->doStashFile()->getFileKey(); } /** @@ -987,7 +1007,7 @@ abstract class UploadBase { */ public function stashSession() { wfDeprecated( __METHOD__, '1.28' ); - return $this->stashFile()->getFileKey(); + return $this->doStashFile()->getFileKey(); } /**