Break long lines in Action classes
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Nov 2013 11:33:19 +0000 (12:33 +0100)
committerChad <chadh@wikimedia.org>
Thu, 14 Nov 2013 18:18:49 +0000 (18:18 +0000)
Fixes CodeSniffer errors and warnigs.

Change-Id: Ic9cf4b9c677b3168d7c9820e2694080907997ee3

includes/actions/CachedAction.php
includes/actions/HistoryAction.php
includes/actions/RawAction.php
includes/actions/RevertAction.php
includes/actions/RollbackAction.php
includes/actions/WatchAction.php

index f3ce25b..186ad46 100644 (file)
@@ -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
         *
index d9eba9c..687a460 100644 (file)
@@ -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 ) . '&#160;' .
+                       Xml::dateMenu(
+                               ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ),
+                               $month
+                       ) . '&#160;' .
                        ( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) .
                        $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;
index 1213bfb..1a451b7 100644 (file)
@@ -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;
index 0a7ef9f..e5f1929 100644 (file)
@@ -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() {
index 81bad9d..d48a0ea 100644 (file)
@@ -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( '', '' );
                }
        }
index 054d615..e1b5d52 100644 (file)
@@ -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' );
                }