Try to make a dent in CodeSniffer reports on includes/ (1)
authorSiebrand Mazeland <siebrand@kitano.nl>
Sun, 23 Mar 2014 01:28:57 +0000 (02:28 +0100)
committerSiebrand <siebrand@kitano.nl>
Sun, 23 Mar 2014 01:29:41 +0000 (01:29 +0000)
Change-Id: Iaf3120b4e32cc5835ef9ed86236d98679e2b87fa

includes/AjaxResponse.php
includes/Article.php
includes/Autopromote.php
includes/Block.php
includes/CacheHelper.php
includes/Category.php
includes/CategoryViewer.php
includes/ChangeTags.php
includes/DefaultSettings.php
includes/Export.php

index 334cee3..4b5ca75 100644 (file)
@@ -28,7 +28,6 @@
  * @ingroup Ajax
  */
 class AjaxResponse {
-
        /**
         * Number of seconds to get the response cached by a proxy
         * @var int $mCacheDuration
@@ -184,10 +183,10 @@ class AjaxResponse {
                                }
 
                        } else {
-
                                # Let the client do the caching. Cache is not purged.
                                header ( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT" );
-                               header ( "Cache-Control: s-maxage={$this->mCacheDuration},public,max-age={$this->mCacheDuration}" );
+                               header ( "Cache-Control: s-maxage={$this->mCacheDuration}," .
+                                       "public,max-age={$this->mCacheDuration}" );
                        }
 
                } else {
@@ -237,17 +236,22 @@ class AjaxResponse {
                        wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", 'log' );
                        wfDebug( "$fname: --  we might send Last-Modified : $lastmod\n", 'log' );
 
-                       if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
+                       if ( ( $ismodsince >= $timestamp )
+                               && $wgUser->validateCache( $ismodsince ) &&
+                               $ismodsince >= $wgCacheEpoch
+                       ) {
                                ini_set( 'zlib.output_compression', 0 );
                                $this->setResponseCode( "304 Not Modified" );
                                $this->disable();
                                $this->mLastModified = $lastmod;
 
-                               wfDebug( "$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", 'log' );
+                               wfDebug( "$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
+                                       "page: $timestamp ; site $wgCacheEpoch\n", 'log' );
 
                                return true;
                        } else {
-                               wfDebug( "$fname: READY  client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", 'log' );
+                               wfDebug( "$fname: READY  client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
+                                       "page: $timestamp ; site $wgCacheEpoch\n", 'log' );
                                $this->mLastModified = $lastmod;
                        }
                } else {
index b132ca9..d45b332 100644 (file)
@@ -367,9 +367,11 @@ class Article implements Page {
         * Does *NOT* follow redirects.
         *
         * @protected
-        * @note this is really internal functionality that should really NOT be used by other functions. For accessing
-        *       article content, use the WikiPage class, especially WikiBase::getContent(). However, a lot of legacy code
-        *       uses this method to retrieve page text from the database, so the function has to remain public for now.
+        * @note This is really internal functionality that should really NOT be
+        * used by other functions. For accessing article content, use the WikiPage
+        * class, especially WikiBase::getContent(). However, a lot of legacy code
+        * uses this method to retrieve page text from the database, so the function
+        * has to remain public for now.
         *
         * @return mixed string containing article contents, or false if null
         * @deprecated in 1.21, use WikiPage::getContent() instead
@@ -397,9 +399,10 @@ class Article implements Page {
        /**
         * Get text content object
         * Does *NOT* follow redirects.
-        * TODO: when is this null?
+        * @todo When is this null?
         *
-        * @note code that wants to retrieve page content from the database should use WikiPage::getContent().
+        * @note Code that wants to retrieve page content from the database should
+        * use WikiPage::getContent().
         *
         * @return Content|null|boolean false
         *
@@ -434,7 +437,8 @@ class Article implements Page {
                        }
                } else {
                        if ( !$this->mPage->getLatest() ) {
-                               wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" );
+                               wfDebug( __METHOD__ . " failed to find page data for title " .
+                                       $this->getTitle()->getPrefixedText() . "\n" );
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
@@ -442,7 +446,8 @@ class Article implements Page {
                        $this->mRevision = $this->mPage->getRevision();
 
                        if ( !$this->mRevision ) {
-                               wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" );
+                               wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " .
+                                       $this->mPage->getLatest() . "\n" );
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
@@ -450,7 +455,11 @@ class Article implements Page {
 
                // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
                // We should instead work with the Revision object when we need it...
-               $this->mContentObject = $this->mRevision->getContent( Revision::FOR_THIS_USER, $this->getContext()->getUser() ); // Loads if user is allowed
+               // Loads if user is allowed
+               $this->mContentObject = $this->mRevision->getContent(
+                       Revision::FOR_THIS_USER,
+                       $this->getContext()->getUser()
+               );
                $this->mRevIdFetched = $this->mRevision->getId();
 
                wfRunHooks( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
@@ -711,7 +720,8 @@ class Article implements Page {
                                        # Don't cache a dirty ParserOutput object
                                        if ( $poolArticleView->getIsDirty() ) {
                                                $outputPage->setSquidMaxage( 0 );
-                                               $outputPage->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
+                                               $outputPage->addHTML( "<!-- parser cache is expired, " .
+                                                       "sending anyway due to pool overload-->\n" );
                                        }
 
                                        $outputDone = true;
@@ -794,13 +804,21 @@ class Article implements Page {
                }
 
                $contentHandler = $rev->getContentHandler();
-               $de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
+               $de = $contentHandler->createDifferenceEngine(
+                       $this->getContext(),
+                       $oldid,
+                       $diff,
+                       $rcid,
+                       $purge,
+                       $unhide
+               );
 
                // DifferenceEngine directly fetched the revision:
                $this->mRevIdFetched = $de->mNewid;
                $de->showDiffPage( $diffOnly );
 
-               // Run view updates for the newer revision being diffed (and shown below the diff if not $diffOnly)
+               // Run view updates for the newer revision being diffed (and shown
+               // below the diff if not $diffOnly).
                list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
                // New can be false, convert it to 0 - this conveniently means the latest revision
                $this->mPage->doViewUpdates( $user, (int)$new );
@@ -813,7 +831,8 @@ class Article implements Page {
         * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
         * page views.
         *
-        * @param bool $showCacheHint whether to show a message telling the user to clear the browser cache (default: true).
+        * @param bool $showCacheHint whether to show a message telling the user
+        *   to clear the browser cache (default: true).
         */
        protected function showCssOrJsPage( $showCacheHint = true ) {
                $outputPage = $this->getContext()->getOutput();
@@ -822,15 +841,20 @@ class Article implements Page {
                        $dir = $this->getContext()->getLanguage()->getDir();
                        $lang = $this->getContext()->getLanguage()->getCode();
 
-                       $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
-                               'clearyourcache' );
+                       $outputPage->wrapWikiMsg(
+                               "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
+                               'clearyourcache'
+                       );
                }
 
                $this->fetchContentObject();
 
                if ( $this->mContentObject ) {
                        // Give hooks a chance to customise the output
-                       if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->mContentObject, $this->getTitle(), $outputPage ) ) ) {
+                       if ( ContentHandler::runLegacyHooks(
+                               'ShowRawCssJs',
+                               array( $this->mContentObject, $this->getTitle(), $outputPage ) )
+                       ) {
                                $po = $this->mContentObject->getParserOutput( $this->getTitle() );
                                $outputPage->addHTML( $po->getText() );
                        }
@@ -1007,7 +1031,10 @@ class Article implements Page {
        public function showNamespaceHeader() {
                if ( $this->getTitle()->isTalkPage() ) {
                        if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
-                               $this->getContext()->getOutput()->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
+                               $this->getContext()->getOutput()->wrapWikiMsg(
+                                       "<div class=\"mw-talkpageheader\">\n$1\n</div>",
+                                       array( 'talkpageheader' )
+                               );
                        }
                }
        }
@@ -1017,7 +1044,9 @@ class Article implements Page {
         */
        public function showViewFooter() {
                # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
-               if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) {
+               if ( $this->getTitle()->getNamespace() == NS_USER_TALK
+                       && IP::isValid( $this->getTitle()->getText() )
+               ) {
                        $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
                }
 
@@ -1025,7 +1054,6 @@ class Article implements Page {
                $patrolFooterShown = $this->showPatrolFooter();
 
                wfRunHooks( 'ArticleViewFooter', array( $this, $patrolFooterShown ) );
-
        }
 
        /**
@@ -1045,7 +1073,9 @@ class Article implements Page {
                $cache = wfGetMainCache();
                $rc = false;
 
-               if ( !$this->getTitle()->quickUserCan( 'patrol', $user ) || !( $wgUseRCPatrol || $wgUseNPPatrol ) ) {
+               if ( !$this->getTitle()->quickUserCan( 'patrol', $user )
+                       || !( $wgUseRCPatrol || $wgUseNPPatrol )
+               ) {
                        // Patrolling is disabled or the user isn't allowed to
                        return false;
                }
@@ -1064,7 +1094,9 @@ class Article implements Page {
                        return false;
                }
 
-               if ( $this->mRevision && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 ) ) {
+               if ( $this->mRevision
+                       && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
+               ) {
                        // The current revision is already older than what could be in the RC table
                        // 6h tolerance because the RC might not be cleaned out regularly
                        wfProfileOut( __METHOD__ );
@@ -1079,7 +1111,9 @@ class Article implements Page {
                        __METHOD__
                );
 
-               if ( $oldestRevisionTimestamp && RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 ) ) {
+               if ( $oldestRevisionTimestamp
+                       && RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
+               ) {
                        // 6h tolerance because the RC might not be cleaned out regularly
                        $rc = RecentChange::newFromConds(
                                array(
@@ -1153,7 +1187,9 @@ class Article implements Page {
                $validUserPage = false;
 
                # Show info in user (talk) namespace. Does the user exist? Is he blocked?
-               if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
+               if ( $this->getTitle()->getNamespace() == NS_USER
+                       || $this->getTitle()->getNamespace() == NS_USER_TALK
+               ) {
                        $parts = explode( '/', $this->getTitle()->getText() );
                        $rootPart = $parts[0];
                        $user = User::newFromName( $rootPart, false /* allow IP users*/ );
@@ -1446,9 +1482,7 @@ class Article implements Page {
 
                // the loop prepends the arrow image before the link, so the first case needs to be outside
 
-               /**
-                * @var $title Title
-                */
+               /** @var $title Title */
                $title = array_shift( $target );
 
                if ( $forceKnown ) {
@@ -1459,13 +1493,27 @@ class Article implements Page {
 
                $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
                $alt = $lang->isRTL() ? '←' : '→';
-               // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
+
+               // Automatically append redirect=no to each link, since most of them are
+               // redirect pages themselves.
+               /** @var Title $rt */
                foreach ( $target as $rt ) {
                        $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
                        if ( $forceKnown ) {
-                               $link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
+                               $link .= Linker::linkKnown(
+                                       $rt,
+                                       htmlspecialchars( $rt->getFullText(),
+                                       array(),
+                                       array( 'redirect' => 'no' )
+                               )
+                               );
                        } else {
-                               $link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
+                               $link .= Linker::link(
+                                       $rt,
+                                       htmlspecialchars( $rt->getFullText() ),
+                                       array(),
+                                       array( 'redirect' => 'no' )
+                               );
                        }
                }
 
@@ -1572,7 +1620,8 @@ class Article implements Page {
                        try {
                                $reason = $this->generateReason( $hasHistory );
                        } catch ( MWException $e ) {
-                               # if a page is horribly broken, we still want to be able to delete it. so be lenient about errors here.
+                               # if a page is horribly broken, we still want to be able to
+                               # delete it. So be lenient about errors here.
                                wfDebug( "Error while building auto delete summary: $e" );
                                $reason = '';
                        }
@@ -1594,7 +1643,11 @@ class Article implements Page {
                        if ( $this->mTitle->isBigDeletion() ) {
                                global $wgDeleteRevisionsLimit;
                                $this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
-                                       array( 'delete-warning-toobig', $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) ) );
+                                       array(
+                                               'delete-warning-toobig',
+                                               $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
+                                       )
+                               );
                        }
                }
 
@@ -1647,9 +1700,14 @@ class Article implements Page {
                                        Xml::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
                                "</td>
                                <td class='mw-input'>" .
-                                       Xml::listDropDown( 'wpDeleteReasonList',
+                                       Xml::listDropDown(
+                                               'wpDeleteReasonList',
                                                wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
-                                               wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(), '', 'wpReasonDropDown', 1 ) .
+                                               wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
+                                               '',
+                                               'wpReasonDropDown',
+                                               1
+                                       ) .
                                "</td>
                        </tr>
                        <tr id=\"wpDeleteReasonRow\">
@@ -1690,7 +1748,10 @@ class Article implements Page {
                        </tr>" .
                        Xml::closeElement( 'table' ) .
                        Xml::closeElement( 'fieldset' ) .
-                       Html::hidden( 'wpEditToken', $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) ) ) .
+                       Html::hidden(
+                               'wpEditToken',
+                               $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) )
+                       ) .
                        Xml::closeElement( 'form' );
 
                        if ( $user->isAllowed( 'editinterface' ) ) {
@@ -1715,13 +1776,14 @@ class Article implements Page {
 
        /**
         * Perform a deletion and output success or failure messages
-        * @param $reason
-        * @param $suppress bool
+        * @param string $reason
+        * @param bool $suppress
         */
        public function doDelete( $reason, $suppress = false ) {
                $error = '';
                $outputPage = $this->getContext()->getOutput();
                $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
+
                if ( $status->isGood() ) {
                        $deleted = $this->getTitle()->getPrefixedText();
 
@@ -1733,7 +1795,11 @@ class Article implements Page {
                        $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
                        $outputPage->returnToMain( false );
                } else {
-                       $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
+                       $outputPage->setPageTitle(
+                               wfMessage( 'cannotdelete-title',
+                                       $this->getTitle()->getPrefixedText() )
+                       );
+
                        if ( $error == '' ) {
                                $outputPage->addWikiText(
                                        "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
@@ -1878,7 +1944,8 @@ class Article implements Page {
                if ( $this->mContext instanceof IContextSource ) {
                        return $this->mContext;
                } else {
-                       wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
+                       wfDebug( __METHOD__ . " called and \$mContext is null. " .
+                               "Return RequestContext::getMain(); for sanity\n" );
                        return RequestContext::getMain();
                }
        }
@@ -1978,7 +2045,9 @@ class Article implements Page {
         * @param $user User
         * @return Status
         */
-       public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
+       public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
+               $reason, User $user
+       ) {
                return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
        }
 
@@ -1989,7 +2058,9 @@ class Article implements Page {
         * @param $expiry array
         * @return bool
         */
-       public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
+       public function updateRestrictions( $limit = array(), $reason = '',
+               &$cascade = 0, $expiry = array()
+       ) {
                return $this->mPage->doUpdateRestrictions(
                        $limit,
                        $expiry,
@@ -2007,7 +2078,9 @@ class Article implements Page {
         * @param $error string
         * @return bool
         */
-       public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
+       public function doDeleteArticle( $reason, $suppress = false, $id = 0,
+               $commit = true, &$error = ''
+       ) {
                return $this->mPage->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
        }
 
index 170d7ab..197ad9c 100644 (file)
@@ -197,7 +197,8 @@ class Autopromote {
                                return in_array( 'bot', User::getGroupPermissions( $user->getGroups() ) );
                        default:
                                $result = null;
-                               wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), $user, &$result ) );
+                               wfRunHooks( 'AutopromoteCondition', array( $cond[0],
+                                       array_slice( $cond, 1 ), $user, &$result ) );
                                if ( $result === null ) {
                                        throw new MWException( "Unrecognized condition {$cond[0]} for autopromotion!" );
                                }
index 3575b9d..c366052 100644 (file)
@@ -435,7 +435,8 @@ class Block {
         * Update a block in the DB with new parameters.
         * The ID field needs to be loaded first.
         *
-        * @return bool|array False on failure, array on success: ('id' => block ID, 'autoIds' => array of autoblock IDs)
+        * @return bool|array False on failure, array on success:
+        *   ('id' => block ID, 'autoIds' => array of autoblock IDs)
         */
        public function update() {
                wfDebug( "Block::update; timestamp {$this->mTimestamp}\n" );
@@ -676,7 +677,8 @@ class Block {
                wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" );
                $autoblock->setTarget( $autoblockIP );
                $autoblock->setBlocker( $this->getBlocker() );
-               $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )->inContentLanguage()->plain();
+               $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )
+                       ->inContentLanguage()->plain();
                $timestamp = wfTimestampNow();
                $autoblock->mTimestamp = $timestamp;
                $autoblock->mAuto = 1;
@@ -973,7 +975,10 @@ class Block {
                        # passed by some callers (bug 29116)
                        return null;
 
-               } elseif ( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) {
+               } elseif ( in_array(
+                       $type,
+                       array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) )
+               ) {
                        $block = new Block();
                        $block->fromMaster( $fromMaster );
 
index f6cd3a6..cfa4160 100644 (file)
@@ -28,7 +28,6 @@
  * @since 1.20
  */
 interface ICacheHelper {
-
        /**
         * Sets if the cache should be enabled or not.
         *
@@ -81,7 +80,6 @@ interface ICacheHelper {
         * @param integer $cacheExpiry
         */
        function setExpiry( $cacheExpiry );
-
 }
 
 /**
@@ -103,7 +101,6 @@ interface ICacheHelper {
  * @since 1.20
  */
 class CacheHelper implements ICacheHelper {
-
        /**
         * The time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.
         *
@@ -275,7 +272,8 @@ class CacheHelper implements ICacheHelper {
                                $itemKey = array_shift( $itemKey );
 
                                if ( !is_integer( $itemKey ) ) {
-                                       wfWarn( "Attempted to get item with non-numeric key while the next item in the queue has a key ($itemKey) in " . __METHOD__ );
+                                       wfWarn( "Attempted to get item with non-numeric key while " .
+                                               "the next item in the queue has a key ($itemKey) in " . __METHOD__ );
                                } elseif ( is_null( $itemKey ) ) {
                                        wfWarn( "Attempted to get an item while the queue is empty in " . __METHOD__ );
                                } else {
@@ -316,7 +314,11 @@ class CacheHelper implements ICacheHelper {
         */
        public function saveCache() {
                if ( $this->cacheEnabled && $this->hasCached === false && !empty( $this->cachedChunks ) ) {
-                       wfGetCache( CACHE_ANYTHING )->set( $this->getCacheKeyString(), $this->cachedChunks, $this->cacheExpiry );
+                       wfGetCache( CACHE_ANYTHING )->set(
+                               $this->getCacheKeyString(),
+                               $this->cachedChunks,
+                               $this->cacheExpiry
+                       );
                }
        }
 
@@ -381,5 +383,4 @@ class CacheHelper implements ICacheHelper {
        public function setOnInitializedHandler( $handlerFunction ) {
                $this->onInitHandler = $handlerFunction;
        }
-
 }
index df5ad7d..e326ce2 100644 (file)
@@ -26,7 +26,7 @@
  * like to refresh link counts, the objects will be appropriately reinitialized.
  * Member variables are lazy-initialized.
  *
- * TODO: Move some stuff from CategoryPage.php to here, and use that.
+ * @todo Move some stuff from CategoryPage.php to here, and use that.
  */
 class Category {
        /** Name of the category, normalized to DB-key form */
@@ -75,7 +75,8 @@ class Category {
                if ( !$row ) {
                        # Okay, there were no contents.  Nothing to initialize.
                        if ( $this->mTitle ) {
-                               # If there is a title object but no record in the category table, treat this as an empty category
+                               # If there is a title object but no record in the category table,
+                               # treat this as an empty category.
                                $this->mID = false;
                                $this->mName = $this->mTitle->getDBkey();
                                $this->mPages = 0;
@@ -155,11 +156,13 @@ class Category {
        /**
         * Factory function, for constructing a Category object from a result set
         *
-        * @param $row result set row, must contain the cat_xxx fields. If the fields are null,
-        *        the resulting Category object will represent an empty category if a title object
-        *        was given. If the fields are null and no title was given, this method fails and returns false.
-        * @param Title $title optional title object for the category represented by the given row.
-        *        May be provided if it is already known, to avoid having to re-create a title object later.
+        * @param $row Result set row, must contain the cat_xxx fields. If the
+        *   fields are null, the resulting Category object will represent an empty
+        *   category if a title object was given. If the fields are null and no
+        *   title was given, this method fails and returns false.
+        * @param Title $title optional title object for the category represented by
+        *   the given row. May be provided if it is already known, to avoid having
+        *   to re-create a title object later.
         * @return Category
         */
        public static function newFromRow( $row, $title = null ) {
@@ -177,7 +180,8 @@ class Category {
                                # but we can't know that here...
                                return false;
                        } else {
-                               $cat->mName = $title->getDBkey(); # if we have a title object, fetch the category name from there
+                               # if we have a title object, fetch the category name from there
+                               $cat->mName = $title->getDBkey();
                        }
 
                        $cat->mID = false;
index 4027bef..183c5f2 100644 (file)
@@ -76,7 +76,9 @@ class CategoryViewer extends ContextSource {
         * @param array $until An array with 3 keys for until of each section (since 1.17)
         * @param $query Array
         */
-       function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) {
+       function __construct( $title, IContextSource $context, $from = array(),
+               $until = array(), $query = array()
+       ) {
                global $wgCategoryPagingLimit;
                $this->title = $title;
                $this->setContext( $context );
@@ -423,7 +425,12 @@ class CategoryViewer extends ContextSource {
                        $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
 
                        $r .= "<div id=\"mw-category-media\">\n";
-                       $r .= '<h2>' . $this->msg( 'category-media-header', wfEscapeWikiText( $this->title->getText() ) )->text() . "</h2>\n";
+                       $r .= '<h2>' .
+                               $this->msg(
+                                       'category-media-header',
+                                       wfEscapeWikiText( $this->title->getText() )
+                               )->text() .
+                               "</h2>\n";
                        $r .= $countmsg;
                        $r .= $this->getSectionPagingLinks( 'file' );
                        if ( $this->showGallery ) {
@@ -447,7 +454,9 @@ class CategoryViewer extends ContextSource {
        private function getSectionPagingLinks( $type ) {
                if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
                        return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type );
-               } elseif ( $this->nextPage[$type] !== null || ( isset( $this->from[$type] ) && $this->from[$type] !== null ) ) {
+               } elseif ( $this->nextPage[$type] !== null
+                       || ( isset( $this->from[$type] ) && $this->from[$type] !== null )
+               ) {
                        return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
                } else {
                        return '';
@@ -562,7 +571,8 @@ class CategoryViewer extends ContextSource {
        static function shortList( $articles, $articles_start_char ) {
                $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
                $r .= '<ul><li>' . $articles[0] . '</li>';
-               for ( $index = 1; $index < count( $articles ); $index++ ) {
+               $articleCount = count( $articles );
+               for ( $index = 1; $index < $articleCount; $index++ ) {
                        if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
                                $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
                        }
index 53f2955..f73ec1f 100644 (file)
  */
 
 class ChangeTags {
-
        /**
         * Creates HTML for the given tags
         *
         * @param string $tags Comma-separated list of tags
         * @param string $page A label for the type of action which is being displayed,
-        *                     for example: 'history', 'contributions' or 'newpages'
-        *
-        * @return Array with two items: (html, classes)
-        *            - html: String: HTML for displaying the tags (empty string when param $tags is empty)
-        *            - classes: Array of strings: CSS classes used in the generated html, one class for each tag
-        *
+        *   for example: 'history', 'contributions' or 'newpages'
+        * @return array Array with two items: (html, classes)
+        *   - html: String: HTML for displaying the tags (empty string when param $tags is empty)
+        *   - classes: Array of strings: CSS classes used in the generated html, one class for each tag
         */
        public static function formatSummaryRow( $tags, $page ) {
                global $wgLang;
@@ -90,7 +87,9 @@ class ChangeTags {
         *
         * @exception MWException when $rc_id, $rev_id and $log_id are all null
         */
-       public static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) {
+       public static function addTags( $tags, $rc_id = null, $rev_id = null,
+               $log_id = null, $params = null
+       ) {
                if ( !is_array( $tags ) ) {
                        $tags = array( $tags );
                }
@@ -106,19 +105,45 @@ class ChangeTags {
 
                // Might as well look for rcids and so on.
                if ( !$rc_id ) {
-                       $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
+                       // Info might be out of date, somewhat fractionally, on slave.
+                       $dbr = wfGetDB( DB_MASTER );
                        if ( $log_id ) {
-                               $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
+                               $rc_id = $dbr->selectField(
+                                       'recentchanges',
+                                       'rc_id',
+                                       array( 'rc_logid' => $log_id ),
+                                       __METHOD__
+                               );
                        } elseif ( $rev_id ) {
-                               $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ );
+                               $rc_id = $dbr->selectField(
+                                       'recentchanges',
+                                       'rc_id',
+                                       array( 'rc_this_oldid' => $rev_id ),
+                                       __METHOD__
+                               );
                        }
                } elseif ( !$log_id && !$rev_id ) {
-                       $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
-                       $log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ );
-                       $rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ );
+                       // Info might be out of date, somewhat fractionally, on slave.
+                       $dbr = wfGetDB( DB_MASTER );
+                       $log_id = $dbr->selectField(
+                               'recentchanges',
+                               'rc_logid',
+                               array( 'rc_id' => $rc_id ),
+                               __METHOD__
+                       );
+                       $rev_id = $dbr->selectField(
+                               'recentchanges',
+                               'rc_this_oldid',
+                               array( 'rc_id' => $rc_id ),
+                               __METHOD__
+                       );
                }
 
-               $tsConds = array_filter( array( 'ts_rc_id' => $rc_id, 'ts_rev_id' => $rev_id, 'ts_log_id' => $log_id ) );
+               $tsConds = array_filter( array(
+                       'ts_rc_id' => $rc_id,
+                       'ts_rev_id' => $rev_id,
+                       'ts_log_id' => $log_id )
+               );
 
                ## Update the summary row.
                $prevTags = $dbr->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
@@ -222,24 +247,45 @@ class ChangeTags {
         *        - if $fullForm is false: Array with
         *        - if $fullForm is true: String, html fragment
         */
-       public static function buildTagFilterSelector( $selected = '', $fullForm = false, Title $title = null ) {
+       public static function buildTagFilterSelector( $selected = '',
+               $fullForm = false, Title $title = null
+       ) {
                global $wgUseTagFilter;
 
                if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) {
                        return $fullForm ? '' : array();
                }
 
-               $data = array( Html::rawElement( 'label', array( 'for' => 'tagfilter' ), wfMessage( 'tag-filter' )->parse() ),
-                       Xml::input( 'tagfilter', 20, $selected, array( 'class' => 'mw-tagfilter-input', 'id' => 'tagfilter' ) ) );
+               $data = array(
+                       Html::rawElement(
+                               'label',
+                               array( 'for' => 'tagfilter' ),
+                               wfMessage( 'tag-filter' )->parse()
+                       ),
+                       Xml::input(
+                               'tagfilter',
+                               20,
+                               $selected,
+                               array( 'class' => 'mw-tagfilter-input', 'id' => 'tagfilter' )
+                       )
+               );
 
                if ( !$fullForm ) {
                        return $data;
                }
 
                $html = implode( '&#160;', $data );
-               $html .= "\n" . Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMessage( 'tag-filter-submit' )->text() ) );
+               $html .= "\n" .
+                       Xml::element(
+                               'input',
+                               array( 'type' => 'submit', 'value' => wfMessage( 'tag-filter-submit' )->text() )
+                       );
                $html .= "\n" . Html::hidden( 'title', $title->getPrefixedText() );
-               $html = Xml::tags( 'form', array( 'action' => $title->getLocalURL(), 'class' => 'mw-tagfilter-form', 'method' => 'get' ), $html );
+               $html = Xml::tags(
+                       'form',
+                       array( 'action' => $title->getLocalURL(), 'class' => 'mw-tagfilter-form', 'method' => 'get' ),
+                       $html
+               );
 
                return $html;
        }
index c35070a..efef9e0 100644 (file)
@@ -5531,9 +5531,10 @@ $wgGitBin = '/usr/bin/git';
  * @since 1.20
  */
 $wgGitRepositoryViewers = array(
-       'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' => 'https://git.wikimedia.org/commit/%r/%H',
-       'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)'
-               => 'https://git.wikimedia.org/commit/%r/%H',
+       'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
+               'https://git.wikimedia.org/commit/%r/%H',
+       'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
+               'https://git.wikimedia.org/commit/%r/%H',
 );
 
 /** @} */ # End of maintenance }
index 56fe452..4c0eb30 100644 (file)
@@ -594,9 +594,8 @@ class XmlDumpWriter {
         *
         * @param $row object
         * @return string
-        * @access private
         */
-       function openPage( $row ) {
+       public function openPage( $row ) {
                $out = "  <page>\n";
                $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                $out .= '    ' . Xml::elementClean( 'title', array(), self::canonicalTitle( $title ) ) . "\n";
@@ -606,7 +605,9 @@ class XmlDumpWriter {
                        $page = WikiPage::factory( $title );
                        $redirect = $page->getRedirectTarget();
                        if ( $redirect instanceof Title && $redirect->isValidRedirectTarget() ) {
-                               $out .= '    ' . Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) ) . "\n";
+                               $out .= '    ';
+                               $out .= Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) );
+                               $out .= "\n";
                        }
                }
 
@@ -680,7 +681,10 @@ class XmlDumpWriter {
                                "" ) . "\n";
                }
 
-               if ( isset( $row->rev_sha1 ) && $row->rev_sha1 && !( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
+               if ( isset( $row->rev_sha1 )
+                       && $row->rev_sha1
+                       && !( $row->rev_deleted & Revision::DELETED_TEXT )
+               ) {
                        $out .= "      " . Xml::element( 'sha1', null, strval( $row->rev_sha1 ) ) . "\n";
                } else {
                        $out .= "      <sha1/>\n";
@@ -813,7 +817,7 @@ class XmlDumpWriter {
        }
 
        /**
-        * @param $file File
+        * @param File $file
         * @param $dumpContents bool
         * @return string
         */
@@ -828,7 +832,7 @@ class XmlDumpWriter {
                        $be = $file->getRepo()->getBackend();
                        # Dump file as base64
                        # Uses only XML-safe characters, so does not need escaping
-                       # @TODO: too bad this loads the contents into memory (script might swap)
+                       # @todo Too bad this loads the contents into memory (script might swap)
                        $contents = '      <contents encoding="base64">' .
                                chunk_split( base64_encode(
                                        $be->getFileContents( array( 'src' => $file->getPath() ) ) ) ) .
@@ -956,7 +960,8 @@ class DumpOutput {
         * Use this for the last piece of a file written out
         * at specified checkpoints (e.g. every n hours).
         * @param $newname mixed File name. May be a string or an array with one element
-        * @param bool $open If true, a new file with the old filename will be opened again for writing (default: false)
+        * @param bool $open If true, a new file with the old filename will be opened
+        *   again for writing (default: false)
         */
        function closeAndRename( $newname, $open = false ) {
        }