X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialUploadStash.php;h=ad329d3e80be6d375820d7773eec20d923d623e3;hb=b51076a84446d157bed511246450e70d26e0f945;hp=cb821cb3c48853f3b7ad8375eb1d8f8688ae4155;hpb=acf291598a5e03e032321f7d1208b1ebb6d86c3e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index cb821cb3c4..ad329d3e80 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -48,10 +48,6 @@ class SpecialUploadStash extends UnlistedSpecialPage { public function __construct() { parent::__construct( 'UploadStash', 'upload' ); - try { - $this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); - } catch ( UploadStashNotAvailableException $e ) { - } } /** @@ -62,6 +58,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { * @return bool Success */ public function execute( $subPage ) { + $this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $this->getUser() ); $this->checkPermissions(); if ( $subPage === null || $subPage === '' ) { @@ -159,15 +156,13 @@ class SpecialUploadStash extends UnlistedSpecialPage { * @return bool Success */ private function outputThumbFromStash( $file, $params ) { - // this global, if it exists, points to a "scaler", as you might find in + $flags = 0; + // this config option, if it exists, points to a "scaler", as you might find in // the Wikimedia Foundation cluster. See outputRemoteScaledThumb(). This // is part of our horrible NFS-based system, we create a file on a mount // point here, but fetch the scaled file from somewhere else that // happens to share it over NFS. - global $wgUploadStashScalerBaseUrl; - - $flags = 0; - if ( $wgUploadStashScalerBaseUrl ) { + if ( $this->getConfig()->get( 'UploadStashScalerBaseUrl' ) ) { $this->outputRemoteScaledThumb( $file, $params, $flags ); } else { $this->outputLocallyScaledThumb( $file, $params, $flags ); @@ -199,8 +194,8 @@ class SpecialUploadStash extends UnlistedSpecialPage { throw new UploadStashFileNotFoundException( "no local path for scaled item" ); } - // now we should construct a File, so we can get mime and other such info in a standard way - // n.b. mimetype may be different from original (ogx original -> jpeg thumb) + // now we should construct a File, so we can get MIME and other such info in a standard way + // n.b. MIME type may be different from original (ogx original -> jpeg thumb) $thumbFile = new UnregisteredLocalFile( false, $this->stash->repo, $thumbnailImage->getStoragePath(), false ); if ( !$thumbFile ) { @@ -230,11 +225,10 @@ class SpecialUploadStash extends UnlistedSpecialPage { * @return bool Success */ private function outputRemoteScaledThumb( $file, $params, $flags ) { - // This global probably looks something like - // 'http://upload.wikimedia.org/wikipedia/test/thumb/temp'. Do not use + // This option probably looks something like + // '//upload.wikimedia.org/wikipedia/test/thumb/temp'. Do not use // trailing slash. - global $wgUploadStashScalerBaseUrl; - $scalerBaseUrl = $wgUploadStashScalerBaseUrl; + $scalerBaseUrl = $this->getConfig()->get( 'UploadStashScalerBaseUrl' ); if ( preg_match( '/^\/\//', $scalerBaseUrl ) ) { // this is apparently a protocol-relative URL, which makes no sense in this context, @@ -253,9 +247,9 @@ class SpecialUploadStash extends UnlistedSpecialPage { // make a curl call to the scaler to create a thumbnail $httpOptions = array( 'method' => 'GET', - 'timeout' => 'default' + 'timeout' => 5 // T90599 attempt to time out cleanly ); - $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions ); + $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions, __METHOD__ ); $status = $req->execute(); if ( !$status->isOK() ) { $errors = $status->getErrorsArray(); @@ -295,7 +289,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { * Output HTTP response of raw content * Side effect: writes HTTP response to STDOUT. * @param string $content Content - * @param string $contentType Mime type + * @param string $contentType MIME type * @throws SpecialUploadStashTooLargeException * @return bool */ @@ -313,7 +307,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { /** * Output headers for streaming * @todo Unsure about encoding as binary; if we received from HTTP perhaps - * we should use that encoding, concatted with semicolon to mimeType as it + * we should use that encoding, concatenated with semicolon to `$contentType` as it * usually is. * Side effect: preps PHP to write headers to STDOUT. * @param string $contentType String suitable for content-type header @@ -334,11 +328,12 @@ class SpecialUploadStash extends UnlistedSpecialPage { * This works, because there really is only one stash per logged-in user, despite appearances. * * @param array $formData + * @param HTMLForm $form * @return Status */ - public static function tryClearStashedUploads( $formData ) { + public static function tryClearStashedUploads( $formData, $form ) { if ( isset( $formData['Clear'] ) ) { - $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); + $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $form->getUser() ); wfDebug( 'stash has: ' . print_r( $stash->listFiles(), true ) . "\n" ); if ( !$stash->clear() ) {