From cb8a9bb78a3d3d6c0b16e7ad3a0bb5d09e9f6bcc Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 14 Nov 2013 12:33:19 +0100 Subject: [PATCH] Break long lines in Action classes Fixes CodeSniffer errors and warnigs. Change-Id: Ic9cf4b9c677b3168d7c9820e2694080907997ee3 --- includes/actions/CachedAction.php | 6 ++++-- includes/actions/HistoryAction.php | 23 +++++++++++++++++------ includes/actions/RawAction.php | 15 +++++++++++---- includes/actions/RevertAction.php | 26 +++++++++++++++++++++----- includes/actions/RollbackAction.php | 19 +++++++++++++++---- includes/actions/WatchAction.php | 12 +++++++++--- 6 files changed, 77 insertions(+), 24 deletions(-) diff --git a/includes/actions/CachedAction.php b/includes/actions/CachedAction.php index f3ce25b365..186ad462a8 100644 --- a/includes/actions/CachedAction.php +++ b/includes/actions/CachedAction.php @@ -133,7 +133,8 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * @param string|null $key */ public function addCachedHTML( $computeFunction, $args = array(), $key = null ) { - $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ) ); + $html = $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ); + $this->getOutput()->addHTML( $html ); } /** @@ -147,7 +148,8 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { } /** - * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry. + * Sets the time to live for the cache, in seconds or a unix timestamp + * indicating the point of expiry. * * @since 1.20 * diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index d9eba9ca24..687a4600d1 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -180,7 +180,10 @@ class HistoryAction extends FormlessAction { ) . Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" . Html::hidden( 'action', 'history' ) . "\n" . - Xml::dateMenu( ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ), $month ) . ' ' . + Xml::dateMenu( + ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ), + $month + ) . ' ' . ( $tagSelector ? ( implode( ' ', $tagSelector ) . ' ' ) : '' ) . $checkDeleted . Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" . @@ -535,10 +538,12 @@ class HistoryPager extends ReverseChronologicalPager { * @todo document some more, and maybe clean up the code (some params redundant?) * * @param $row Object: the database row corresponding to the previous line. - * @param $next Mixed: the database row corresponding to the next line. (chronologically previous) + * @param $next Mixed: the database row corresponding to the next line + * (chronologically previous) * @param $notificationtimestamp * @param $latest Boolean: whether this row corresponds to the page's latest revision. - * @param $firstInList Boolean: whether this row corresponds to the first displayed on this history page. + * @param $firstInList Boolean: whether this row corresponds to the first + * displayed on this history page. * @return String: HTML output for the row */ function historyLine( $row, $next, $notificationtimestamp = false, @@ -555,12 +560,14 @@ class HistoryPager extends ReverseChronologicalPager { $curlink = $this->curLink( $rev, $latest ); $lastlink = $this->lastLink( $rev, $next ); - $diffButtons = $this->diffButtons( $rev, $firstInList ); + $curLastlinks = $curlink . $this->historyPage->message['pipe-separator'] . $lastlink; $histLinks = Html::rawElement( 'span', array( 'class' => 'mw-history-histlinks' ), - $this->msg( 'parentheses' )->rawParams( $curlink . $this->historyPage->message['pipe-separator'] . $lastlink )->escaped() + $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped() ); + + $diffButtons = $this->diffButtons( $rev, $firstInList ); $s = $histLinks . $diffButtons; $link = $this->revLink( $rev ); @@ -634,7 +641,11 @@ class HistoryPager extends ReverseChronologicalPager { if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) { if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) { // Get a rollback link without the brackets - $rollbackLink = Linker::generateRollback( $rev, $this->getContext(), array( 'verify', 'noBrackets' ) ); + $rollbackLink = Linker::generateRollback( + $rev, + $this->getContext(), + array( 'verify', 'noBrackets' ) + ); if ( $rollbackLink ) { $this->preventClickjacking(); $tools[] = $rollbackLink; diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 1213bfb949..1a451b74ac 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -96,7 +96,9 @@ class RawAction extends FormlessAction { $privateCache = !User::isEveryoneAllowed( 'read' ) && ( $smaxage == 0 || session_id() != '' ); # allow the client to cache this for 24 hours $mode = $privateCache ? 'private' : 'public'; - $response->header( 'Cache-Control: ' . $mode . ', s-maxage=' . $smaxage . ', max-age=' . $maxage ); + $response->header( + 'Cache-Control: ' . $mode . ', s-maxage=' . $smaxage . ', max-age=' . $maxage + ); $text = $this->getRawText(); @@ -135,8 +137,9 @@ class RawAction extends FormlessAction { // If it's a MediaWiki message we can just hit the message cache if ( $request->getBool( 'usemsgcache' ) && $title->getNamespace() == NS_MEDIAWIKI ) { - // The first "true" is to use the database, the second is to use the content langue - // and the last one is to specify the message key already contains the language in it ("/de", etc.) + // The first "true" is to use the database, the second is to use + // the content langue and the last one is to specify the message + // key already contains the language in it ("/de", etc.). $text = MessageCache::singleton()->get( $title->getDBkey(), true, true, true ); // If the message doesn't exist, return a blank if ( $text === false ) { @@ -178,7 +181,11 @@ class RawAction extends FormlessAction { } if ( $text !== false && $text !== '' && $request->getVal( 'templates' ) === 'expand' ) { - $text = $wgParser->preprocess( $text, $title, ParserOptions::newFromContext( $this->getContext() ) ); + $text = $wgParser->preprocess( + $text, + $title, + ParserOptions::newFromContext( $this->getContext() ) + ); } return $text; diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 0a7ef9ff78..e5f192970b 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -69,7 +69,11 @@ class RevertFileAction extends FormAction { throw new ErrorPageError( 'internalerror', 'unexpected', array( 'oldimage', $oldimage ) ); } - $this->oldFile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->getTitle(), $oldimage ); + $this->oldFile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( + $this->getTitle(), + $oldimage + ); + if ( !$this->oldFile->exists() ) { throw new ErrorPageError( '', 'filerevert-badversion' ); } @@ -100,8 +104,10 @@ class RevertFileAction extends FormAction { 'raw' => true, 'default' => $this->msg( 'filerevert-intro', $this->getTitle()->getText(), $userDate, $userTime, - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), - PROTO_CURRENT ) )->parseAsBlock() + wfExpandUrl( + $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), + PROTO_CURRENT + ) )->parseAsBlock() ), 'comment' => array( 'type' => 'text', @@ -113,11 +119,21 @@ class RevertFileAction extends FormAction { } public function onSubmit( $data ) { - $source = $this->page->getFile()->getArchiveVirtualUrl( $this->getRequest()->getText( 'oldimage' ) ); + $source = $this->page->getFile()->getArchiveVirtualUrl( + $this->getRequest()->getText( 'oldimage' ) + ); $comment = $data['comment']; // TODO: Preserve file properties from database instead of reloading from file - return $this->page->getFile()->upload( $source, $comment, $comment, 0, false, false, $this->getUser() ); + return $this->page->getFile()->upload( + $source, + $comment, + $comment, + 0, + false, + false, + $this->getUser() + ); } public function onSuccess() { diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index 81bad9da0b..d48a0ea227 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -53,7 +53,9 @@ class RollbackAction extends FormlessAction { throw new ThrottledError; } - if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { + if ( isset( $result[0][0] ) && + ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) + ) { $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) ); $errArray = $result[0]; $errMsg = array_shift( $errArray ); @@ -91,12 +93,21 @@ class RollbackAction extends FormlessAction { $old = Linker::revUserTools( $current ); $new = Linker::revUserTools( $target ); - $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new )->parseAsBlock() ); + $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new ) + ->parseAsBlock() ); $this->getOutput()->returnToMain( false, $this->getTitle() ); - if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) { + if ( !$request->getBool( 'hidediff', false ) && + !$this->getUser()->getBoolOption( 'norollbackdiff', false ) + ) { $contentHandler = $current->getContentHandler(); - $de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true ); + $de = $contentHandler->createDifferenceEngine( + $this->getContext(), + $current->getId(), + $newId, + false, + true + ); $de->showDiff( '', '' ); } } diff --git a/includes/actions/WatchAction.php b/includes/actions/WatchAction.php index 054d6154fd..e1b5d52bfa 100644 --- a/includes/actions/WatchAction.php +++ b/includes/actions/WatchAction.php @@ -97,7 +97,9 @@ class WatchAction extends FormAction { * @return Status */ public static function doWatchOrUnwatch( $watch, Title $title, User $user ) { - if ( $user->isLoggedIn() && $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch ) { + if ( $user->isLoggedIn() && + $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch + ) { // If the user doesn't have 'editmywatchlist', we still want to // allow them to add but not remove items via edits and such. if ( $watch ) { @@ -118,8 +120,12 @@ class WatchAction extends FormAction { * @param int $checkRights Passed through to $user->addWatch() * @return Status */ - public static function doWatch( Title $title, User $user, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) { - if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && !$user->isAllowed( 'editmywatchlist' ) ) { + public static function doWatch( Title $title, User $user, + $checkRights = WatchedItem::CHECK_USER_RIGHTS + ) { + if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && + !$user->isAllowed( 'editmywatchlist' ) + ) { return User::newFatalPermissionDeniedStatus( 'editmywatchlist' ); } -- 2.20.1