From 46848c0d1d596733b950aee42a29366b9d1723d5 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 23 Mar 2014 00:59:36 +0100 Subject: [PATCH] Fix CodeSniffer errors and warnings in includes/specials (2) Change-Id: I9787d2a1515b2a8d9310ea636650e20d041acc3d --- includes/specials/SpecialSpecialpages.php | 16 +++- includes/specials/SpecialStatistics.php | 89 +++++++++++-------- .../specials/SpecialUncategorizedimages.php | 3 +- .../specials/SpecialUncategorizedpages.php | 6 +- includes/specials/SpecialUndelete.php | 80 +++++++++++------ includes/specials/SpecialUnusedcategories.php | 7 +- includes/specials/SpecialUnusedtemplates.php | 1 - includes/specials/SpecialUpload.php | 71 ++++++++++----- includes/specials/SpecialUploadStash.php | 56 +++++++----- 9 files changed, 210 insertions(+), 119 deletions(-) diff --git a/includes/specials/SpecialSpecialpages.php b/includes/specials/SpecialSpecialpages.php index 3ed3ac3ed1..3ba50bbd07 100644 --- a/includes/specials/SpecialSpecialpages.php +++ b/includes/specials/SpecialSpecialpages.php @@ -103,9 +103,15 @@ class SpecialSpecialpages extends UnlistedSpecialPage { $middle = ceil( $total / 2 ); $count = 0; - $out->wrapWikiMsg( "

$1

\n", "specialpages-group-$group" ); + $out->wrapWikiMsg( + "

$1

\n", + "specialpages-group-$group" + ); $out->addHTML( - Html::openElement( 'table', array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' ) ) . "\n" . + Html::openElement( + 'table', + array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' ) + ) . "\n" . Html::openElement( 'tr' ) . "\n" . Html::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" . Html::openElement( 'ul' ) . "\n" @@ -124,7 +130,11 @@ class SpecialSpecialpages extends UnlistedSpecialPage { } $link = Linker::linkKnown( $title, htmlspecialchars( $desc ) ); - $out->addHTML( Html::rawElement( 'li', array( 'class' => implode( ' ', $pageClasses ) ), $link ) . "\n" ); + $out->addHTML( Html::rawElement( + 'li', + array( 'class' => implode( ' ', $pageClasses ) ), + $link + ) . "\n" ); # Split up the larger groups $count++; diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index c3a11f3e7a..371e5eac38 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -28,7 +28,6 @@ * @ingroup SpecialPage */ class SpecialStatistics extends SpecialPage { - private $views, $edits, $good, $images, $total, $users, $activeUsers = 0; @@ -107,14 +106,16 @@ class SpecialStatistics extends SpecialPage { /** * Format a row - * @param $text String: description of the row - * @param $number Float: a statistical number - * @param $trExtraParams Array: params to table row, see Html::elememt - * @param $descMsg String: message key + * @param string $text Description of the row + * @param float $number A statistical number + * @param array $trExtraParams Params to table row, see Html::elememt + * @param string $descMsg Message key * @param array|string $descMsgParam Message parameters - * @return string table row in HTML format + * @return string Table row in HTML format */ - private function formatRow( $text, $number, $trExtraParams = array(), $descMsg = '', $descMsgParam = '' ) { + private function formatRow( $text, $number, $trExtraParams = array(), + $descMsg = '', $descMsgParam = '' + ) { if ( $descMsg ) { $msg = $this->msg( $descMsg, $descMsgParam ); if ( $msg->exists() ) { @@ -140,29 +141,32 @@ class SpecialStatistics extends SpecialPage { Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-pages' )->parse() ) . Xml::closeElement( 'tr' ) . $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'Allpages' ), - $this->msg( 'statistics-articles' )->parse() ), - $this->getLanguage()->formatNum( $this->good ), - array( 'class' => 'mw-statistics-articles' ) ) . + $this->msg( 'statistics-articles' )->parse() ), + $this->getLanguage()->formatNum( $this->good ), + array( 'class' => 'mw-statistics-articles' ) ) . $this->formatRow( $this->msg( 'statistics-pages' )->parse(), - $this->getLanguage()->formatNum( $this->total ), - array( 'class' => 'mw-statistics-pages' ), - 'statistics-pages-desc' ) . + $this->getLanguage()->formatNum( $this->total ), + array( 'class' => 'mw-statistics-pages' ), + 'statistics-pages-desc' ) . $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'Listfiles' ), - $this->msg( 'statistics-files' )->parse() ), - $this->getLanguage()->formatNum( $this->images ), - array( 'class' => 'mw-statistics-files' ) ); + $this->msg( 'statistics-files' )->parse() ), + $this->getLanguage()->formatNum( $this->images ), + array( 'class' => 'mw-statistics-files' ) ); } private function getEditStats() { return Xml::openElement( 'tr' ) . Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-edits' )->parse() ) . Xml::closeElement( 'tr' ) . - $this->formatRow( $this->msg( 'statistics-edits' )->parse(), - $this->getLanguage()->formatNum( $this->edits ), - array( 'class' => 'mw-statistics-edits' ) ) . - $this->formatRow( $this->msg( 'statistics-edits-average' )->parse(), - $this->getLanguage()->formatNum( sprintf( '%.2f', $this->total ? $this->edits / $this->total : 0 ) ), - array( 'class' => 'mw-statistics-edits-average' ) ); + $this->formatRow( $this->msg( 'statistics-edits' )->parse(), + $this->getLanguage()->formatNum( $this->edits ), + array( 'class' => 'mw-statistics-edits' ) + ) . + $this->formatRow( $this->msg( 'statistics-edits-average' )->parse(), + $this->getLanguage() + ->formatNum( sprintf( '%.2f', $this->total ? $this->edits / $this->total : 0 ) ), + array( 'class' => 'mw-statistics-edits-average' ) + ); } private function getUserStats() { @@ -171,18 +175,20 @@ class SpecialStatistics extends SpecialPage { return Xml::openElement( 'tr' ) . Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-users' )->parse() ) . Xml::closeElement( 'tr' ) . - $this->formatRow( $this->msg( 'statistics-users' )->parse(), - $this->getLanguage()->formatNum( $this->users ), - array( 'class' => 'mw-statistics-users' ) ) . - $this->formatRow( $this->msg( 'statistics-users-active' )->parse() . ' ' . - Linker::linkKnown( - SpecialPage::getTitleFor( 'Activeusers' ), - $this->msg( 'listgrouprights-members' )->escaped() - ), - $this->getLanguage()->formatNum( $this->activeUsers ), - array( 'class' => 'mw-statistics-users-active' ), - 'statistics-users-active-desc', - $this->getLanguage()->formatNum( $wgActiveUserDays ) ); + $this->formatRow( $this->msg( 'statistics-users' )->parse(), + $this->getLanguage()->formatNum( $this->users ), + array( 'class' => 'mw-statistics-users' ) + ) . + $this->formatRow( $this->msg( 'statistics-users-active' )->parse() . ' ' . + Linker::linkKnown( + SpecialPage::getTitleFor( 'Activeusers' ), + $this->msg( 'listgrouprights-members' )->escaped() + ), + $this->getLanguage()->formatNum( $this->activeUsers ), + array( 'class' => 'mw-statistics-users-active' ), + 'statistics-users-active-desc', + $this->getLanguage()->formatNum( $wgActiveUserDays ) + ); } private function getGroupStats() { @@ -267,7 +273,11 @@ class SpecialStatistics extends SpecialPage { if ( $res->numRows() > 0 ) { $text .= Xml::openElement( 'tr' ); - $text .= Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-mostpopular' )->parse() ); + $text .= Xml::tags( + 'th', + array( 'colspan' => '2' ), + $this->msg( 'statistics-mostpopular' )->parse() + ); $text .= Xml::closeElement( 'tr' ); foreach ( $res as $row ) { @@ -308,7 +318,11 @@ class SpecialStatistics extends SpecialPage { $name = $this->msg( $key )->parse(); $number = htmlspecialchars( $value ); - $return .= $this->formatRow( $name, $this->getLanguage()->formatNum( $number ), array( 'class' => 'mw-statistics-hook', 'id' => 'mw-' . $key ) ); + $return .= $this->formatRow( + $name, + $this->getLanguage()->formatNum( $number ), + array( 'class' => 'mw-statistics-hook', 'id' => 'mw-' . $key ) + ); } } else { // Create the legacy header only once @@ -317,7 +331,8 @@ class SpecialStatistics extends SpecialPage { } // Recursively remap the legacy structure - $return .= $this->getOtherStats( array( 'statistics-header-hooks' => array( $header => $items ) ) ); + $return .= $this->getOtherStats( array( 'statistics-header-hooks' => + array( $header => $items ) ) ); } } diff --git a/includes/specials/SpecialUncategorizedimages.php b/includes/specials/SpecialUncategorizedimages.php index 17de679f26..9060f53a83 100644 --- a/includes/specials/SpecialUncategorizedimages.php +++ b/includes/specials/SpecialUncategorizedimages.php @@ -26,10 +26,9 @@ * Special page lists images which haven't been categorised * * @ingroup SpecialPage + * @todo FIXME: Use an instance of UncategorizedPagesPage or something */ -// @todo FIXME: Use an instance of UncategorizedPagesPage or something class UncategorizedImagesPage extends ImageQueryPage { - function __construct( $name = 'Uncategorizedimages' ) { parent::__construct( $name ); } diff --git a/includes/specials/SpecialUncategorizedpages.php b/includes/specials/SpecialUncategorizedpages.php index c6a4215b6f..8251d5b359 100644 --- a/includes/specials/SpecialUncategorizedpages.php +++ b/includes/specials/SpecialUncategorizedpages.php @@ -25,8 +25,8 @@ * A special page looking for page without any category. * * @ingroup SpecialPage + * @todo FIXME: Make $requestedNamespace selectable, unify all subclasses into one */ -// @todo FIXME: Make $requestedNamespace selectable, unify all subclasses into one class UncategorizedPagesPage extends PageQueryPage { protected $requestedNamespace = false; @@ -58,7 +58,9 @@ class UncategorizedPagesPage extends PageQueryPage { // otherwise, page_namespace is requestedNamespace 'conds' => array( 'cl_from IS NULL', - 'page_namespace' => ( $this->requestedNamespace !== false ? $this->requestedNamespace : MWNamespace::getContentNamespaces() ), + 'page_namespace' => $this->requestedNamespace !== false + ? $this->requestedNamespace + : MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0 ), 'join_conds' => array( diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index acfeb37d23..e8a45a7ae1 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -27,19 +27,13 @@ * @ingroup SpecialPage */ class PageArchive { - /** - * @var Title - */ + /** @var Title */ protected $title; - /** - * @var Status - */ + /** @var Status */ protected $fileStatus; - /** - * @var Status - */ + /** @var Status */ protected $revisionStatus; function __construct( $title ) { @@ -355,16 +349,18 @@ class PageArchive { * Once restored, the items will be removed from the archive tables. * The deletion log will be updated with an undeletion notice. * - * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete. + * @param array $timestamps Pass an empty array to restore all revisions, + * otherwise list the ones to undelete. * @param string $comment * @param array $fileVersions * @param bool $unsuppress * @param User $user User performing the action, or null to use $wgUser - * - * @return array(number of file revisions restored, number of image revisions restored, log message) - * on success, false on failure + * @return array(number of file revisions restored, number of image revisions + * restored, log message) on success, false on failure. */ - function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false, User $user = null ) { + function undelete( $timestamps, $comment = '', $fileVersions = array(), + $unsuppress = false, User $user = null + ) { // If both the set of text revisions and file revisions are empty, // restore everything. Otherwise, just restore the requested items. $restoreAll = empty( $timestamps ) && empty( $fileVersions ); @@ -438,7 +434,8 @@ class PageArchive { * to the cur/old tables. If the page currently exists, all revisions will * be stuffed into old, otherwise the most recent will go into cur. * - * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete. + * @param array $timestamps Pass an empty array to restore all revisions, + * otherwise list the ones to undelete. * @param bool $unsuppress Remove all ar_deleted/fa_deleted restrictions of seletected revs * @param string $comment * @throws ReadOnlyError @@ -638,7 +635,11 @@ class PageArchive { if ( $created || $wasnew ) { // Update site stats, link tables, etc $user = User::newFromName( $revision->getRawUserText(), false ); - $article->doEditUpdates( $revision, $user, array( 'created' => $created, 'oldcountable' => $oldcountable ) ); + $article->doEditUpdates( + $revision, + $user, + array( 'created' => $created, 'oldcountable' => $oldcountable ) + ); } wfRunHooks( 'ArticleUndelete', array( &$this->title, $created, $comment ) ); @@ -676,9 +677,7 @@ class SpecialUndelete extends SpecialPage { var $mAction, $mTarget, $mTimestamp, $mRestore, $mInvert, $mFilename; var $mTargetTimestamp, $mAllowed, $mCanView, $mComment, $mToken; - /** - * @var Title - */ + /** @var Title */ var $mTargetObj; function __construct() { @@ -1288,14 +1287,25 @@ class SpecialUndelete extends SpecialPage { Xml::label( $this->msg( 'undeletecomment' )->text(), 'wpComment' ) . " " . - Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment', 'autofocus' => true ) ) . + Xml::input( + 'wpComment', + 50, + $this->mComment, + array( 'id' => 'wpComment', 'autofocus' => true ) + ) . "   " . - Xml::submitButton( $this->msg( 'undeletebtn' )->text(), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) . ' ' . - Xml::submitButton( $this->msg( 'undeleteinvert' )->text(), array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) ) . + Xml::submitButton( + $this->msg( 'undeletebtn' )->text(), + array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) + ) . ' ' . + Xml::submitButton( + $this->msg( 'undeleteinvert' )->text(), + array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) + ) . " " . $unsuppressBox . @@ -1422,7 +1432,17 @@ class SpecialUndelete extends SpecialPage { $revdlink = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj ); $revisionRow = $this->msg( 'undelete-revision-row' ) - ->rawParams( $checkBox, $revdlink, $last, $pageLink, $userLink, $minor, $revTextSize, $comment, $tagSummary ) + ->rawParams( + $checkBox, + $revdlink, + $last, + $pageLink, + $userLink, + $minor, + $revTextSize, + $comment, + $tagSummary + ) ->escaped(); return Xml::tags( 'li', $attribs, $revisionRow ) . "\n"; @@ -1622,13 +1642,23 @@ class SpecialUndelete extends SpecialPage { // Show revision undeletion warnings and errors $status = $archive->getRevisionStatus(); if ( $status && !$status->isGood() ) { - $out->addWikiText( '
' . $status->getWikiText( 'cannotundelete', 'cannotundelete' ) . '
' ); + $out->addWikiText( '
' . + $status->getWikiText( + 'cannotundelete', + 'cannotundelete' + ) . '
' + ); } // Show file undeletion warnings and errors $status = $archive->getFileStatus(); if ( $status && !$status->isGood() ) { - $out->addWikiText( '
' . $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) . '
' ); + $out->addWikiText( '
' . + $status->getWikiText( + 'undelete-error-short', + 'undelete-error-long' + ) . '
' + ); } } diff --git a/includes/specials/SpecialUnusedcategories.php b/includes/specials/SpecialUnusedcategories.php index c897332818..713823bb62 100644 --- a/includes/specials/SpecialUnusedcategories.php +++ b/includes/specials/SpecialUnusedcategories.php @@ -25,15 +25,14 @@ * @ingroup SpecialPage */ class UnusedCategoriesPage extends QueryPage { + function __construct( $name = 'Unusedcategories' ) { + parent::__construct( $name ); + } function isExpensive() { return true; } - function __construct( $name = 'Unusedcategories' ) { - parent::__construct( $name ); - } - function getPageHeader() { return $this->msg( 'unusedcategoriestext' )->parseAsBlock(); } diff --git a/includes/specials/SpecialUnusedtemplates.php b/includes/specials/SpecialUnusedtemplates.php index f7e7a31338..0c2b870708 100644 --- a/includes/specials/SpecialUnusedtemplates.php +++ b/includes/specials/SpecialUnusedtemplates.php @@ -30,7 +30,6 @@ * @ingroup SpecialPage */ class UnusedtemplatesPage extends QueryPage { - function __construct( $name = 'Unusedtemplates' ) { parent::__construct( $name ); } diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 521b361bf0..4887dafc60 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -39,37 +39,45 @@ class SpecialUpload extends SpecialPage { } /** Misc variables **/ - public $mRequest; // The WebRequest or FauxRequest this form is supposed to handle + + /** @var WebRequest|FauxRequest The request this form is supposed to handle */ + public $mRequest; public $mSourceType; - /** - * @var UploadBase - */ + /** @var UploadBase */ public $mUpload; - /** - * @var LocalFile - */ + /** @var LocalFile */ public $mLocalFile; public $mUploadClicked; /** User input variables from the "description" section **/ - public $mDesiredDestName; // The requested target file name + + /** @var string The requested target file name */ + public $mDesiredDestName; public $mComment; public $mLicense; /** User input variables from the root section **/ + public $mIgnoreWarning; public $mWatchthis; public $mCopyrightStatus; public $mCopyrightSource; /** Hidden variables **/ + public $mDestWarningAck; - public $mForReUpload; // The user followed an "overwrite this file" link - public $mCancelUpload; // The user clicked "Cancel and return to upload form" button + + /** @var bool The user followed an "overwrite this file" link */ + public $mForReUpload; + + /** @var bool The user clicked "Cancel and return to upload form" button */ + public $mCancelUpload; public $mTokenOk; - public $mUploadSuccessful = false; // Subclasses can use this to determine whether a file was uploaded + + /** @var bool Subclasses can use this to determine whether a file was uploaded */ + public $mUploadSuccessful = false; /** Text injection points for hooks not using HTMLForm **/ public $uploadFormTextTop; @@ -449,7 +457,14 @@ class SpecialUpload extends SpecialPage { } else { $pageText = false; } - $status = $this->mUpload->performUpload( $this->mComment, $pageText, $this->mWatchthis, $this->getUser() ); + + $status = $this->mUpload->performUpload( + $this->mComment, + $pageText, + $this->mWatchthis, + $this->getUser() + ); + if ( !$status->isGood() ) { $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) ); @@ -464,13 +479,15 @@ class SpecialUpload extends SpecialPage { /** * Get the initial image page text based on a comment and optional file status information - * @param $comment string - * @param $license string - * @param $copyStatus string - * @param $source string + * @param string $comment + * @param string $license + * @param string $copyStatus + * @param string $source * @return string */ - public static function getInitialPageText( $comment = '', $license = '', $copyStatus = '', $source = '' ) { + public static function getInitialPageText( $comment = '', $license = '', + $copyStatus = '', $source = '' + ) { global $wgUseCopyrightUpload, $wgForceUIMsgAsContentMsg; $msg = array(); @@ -890,23 +907,32 @@ class UploadForm extends HTMLForm { # Print a list of allowed file extensions, if so configured. We ignore # MIME type here, it's incomprehensible to most people and too long. global $wgCheckFileExtensions, $wgStrictFileExtensions, - $wgFileExtensions, $wgFileBlacklist; + $wgFileExtensions, $wgFileBlacklist; if ( $wgCheckFileExtensions ) { if ( $wgStrictFileExtensions ) { # Everything not permitted is banned $extensionsList = '
' . - $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() . + $this->msg( + 'upload-permitted', + $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) + )->parseAsBlock() . "
\n"; } else { # We have to list both preferred and prohibited $extensionsList = '
' . - $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() . + $this->msg( + 'upload-preferred', + $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) + )->parseAsBlock() . "
\n" . '
' . - $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) ) )->parseAsBlock() . + $this->msg( + 'upload-prohibited', + $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) ) + )->parseAsBlock() . "
\n"; } } else { @@ -1072,7 +1098,8 @@ class UploadForm extends HTMLForm { * Add upload JS to the OutputPage */ protected function addUploadJS() { - global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI, $wgStrictFileExtensions; + global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, + $wgEnableAPI, $wgStrictFileExtensions; $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck; $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI; diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 16c348f1cf..964bea1138 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -57,7 +57,8 @@ class SpecialUploadStash extends UnlistedSpecialPage { /** * Execute page -- can output a file directly or show a listing of them. * - * @param string $subPage subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part + * @param string $subPage subpage, e.g. in + * http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part * @return Boolean: success */ public function execute( $subPage ) { @@ -100,7 +101,8 @@ class SpecialUploadStash extends UnlistedSpecialPage { $message = $e->getMessage(); } catch ( SpecialUploadStashTooLargeException $e ) { $code = 500; - $message = 'Cannot serve a file larger than ' . self::MAX_SERVE_BYTES . ' bytes. ' . $e->getMessage(); + $message = 'Cannot serve a file larger than ' . self::MAX_SERVE_BYTES . + ' bytes. ' . $e->getMessage(); } catch ( Exception $e ) { $code = 500; $message = $e->getMessage(); @@ -157,10 +159,11 @@ class SpecialUploadStash extends UnlistedSpecialPage { * @return boolean success */ private function outputThumbFromStash( $file, $params ) { - - // this global, 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 + // this global, 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; @@ -172,16 +175,15 @@ class SpecialUploadStash extends UnlistedSpecialPage { } /** - * Scale a file (probably with a locally installed imagemagick, or similar) and output it to STDOUT. + * Scale a file (probably with a locally installed imagemagick, or similar) + * and output it to STDOUT. * @param $file File * @param array $params Scaling parameters ( e.g. array( width => '50' ) ); * @param int $flags Scaling flags ( see File:: constants ) - * @throws MWException - * @throws UploadStashFileNotFoundException + * @throws MWException|UploadStashFileNotFoundException * @return boolean success */ private function outputLocallyScaledThumb( $file, $params, $flags ) { - // n.b. this is stupid, we insist on re-transforming the file every time we are invoked. We rely // on HTTP caching to ensure this doesn't happen. @@ -209,22 +211,28 @@ class SpecialUploadStash extends UnlistedSpecialPage { } /** - * Scale a file with a remote "scaler", as exists on the Wikimedia Foundation cluster, and output it to STDOUT. - * Note: unlike the usual thumbnail process, the web client never sees the cluster URL; we do the whole HTTP transaction to the scaler ourselves - * and cat the results out. - * Note: We rely on NFS to have propagated the file contents to the scaler. However, we do not rely on the thumbnail being created in NFS and then - * propagated back to our filesystem. Instead we take the results of the HTTP request instead. - * Note: no caching is being done here, although we are instructing the client to cache it forever. + * Scale a file with a remote "scaler", as exists on the Wikimedia Foundation + * cluster, and output it to STDOUT. + * Note: Unlike the usual thumbnail process, the web client never sees the + * cluster URL; we do the whole HTTP transaction to the scaler ourselves + * and cat the results out. + * Note: We rely on NFS to have propagated the file contents to the scaler. + * However, we do not rely on the thumbnail being created in NFS and then + * propagated back to our filesystem. Instead we take the results of the + * HTTP request instead. + * Note: No caching is being done here, although we are instructing the + * client to cache it forever. + * * @param File $file * @param array $params Scaling parameters ( e.g. array( width => '50' ) ); - * @param $flags Scaling flags ( see File:: constants ) + * @param int $flags Scaling flags ( see File:: constants ) * @throws MWException * @return boolean success */ private function outputRemoteScaledThumb( $file, $params, $flags ) { - - // this global probably looks something like 'http://upload.wikimedia.org/wikipedia/test/thumb/temp' - // do not use trailing slash + // This global probably looks something like + // 'http://upload.wikimedia.org/wikipedia/test/thumb/temp'. Do not use + // trailing slash. global $wgUploadStashScalerBaseUrl; $scalerBaseUrl = $wgUploadStashScalerBaseUrl; @@ -267,7 +275,8 @@ class SpecialUploadStash extends UnlistedSpecialPage { * Output HTTP response for file * Side effect: writes HTTP response to STDOUT. * - * @param $file File object with a local path (e.g. UnregisteredLocalFile, LocalFile. Oddly these don't share an ancestor!) + * @param File $file File object with a local path (e.g. UnregisteredLocalFile, + * LocalFile. Oddly these don't share an ancestor!) * @throws SpecialUploadStashTooLargeException * @return bool */ @@ -303,7 +312,9 @@ class SpecialUploadStash extends UnlistedSpecialPage { /** * Output headers for streaming - * XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is. + * @todo Unsure about encoding as binary; if we received from HTTP perhaps + * we should use that encoding, concatted with semicolon to mimeType as it + * usually is. * Side effect: preps PHP to write headers to STDOUT. * @param string $contentType String suitable for content-type header * @param string $size Length in bytes @@ -398,4 +409,3 @@ class SpecialUploadStash extends UnlistedSpecialPage { class SpecialUploadStashTooLargeException extends MWException { } - -- 2.20.1