Update formatting on some API classes (must've forgotten these)
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Nov 2013 12:51:06 +0000 (13:51 +0100)
committerChad <chadh@wikimedia.org>
Thu, 14 Nov 2013 18:13:55 +0000 (18:13 +0000)
Change-Id: I3fe42e75c3029dc76d2d1d40609c9a69aae8e987

includes/api/ApiQueryAllLinks.php
includes/api/ApiQueryAllMessages.php
includes/api/ApiQueryAllPages.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryCategoryInfo.php
includes/api/ApiQueryCategoryMembers.php

index 47d1bce..47f4505 100644 (file)
@@ -177,7 +177,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                $count = 0;
                $result = $this->getResult();
                foreach ( $res as $row ) {
-                       if ( ++ $count > $limit ) {
+                       if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                if ( $params['unique'] ) {
                                        $this->setContinueEnumParameter( 'continue', $row->pl_title );
@@ -258,6 +258,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                if ( !$this->hasNamespace ) {
                        unset( $allowedParams['namespace'] );
                }
+
                return $allowedParams;
        }
 
@@ -287,6 +288,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                if ( !$this->hasNamespace ) {
                        unset( $paramDescription['namespace'] );
                }
+
                return $paramDescription;
        }
 
@@ -309,6 +311,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
        public function getPossibleErrors() {
                $m = $this->getModuleName();
                $what = $this->descriptionWhat;
+
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$what}s mode" ),
                ) );
@@ -319,20 +322,22 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                $name = $this->getModuleName();
                $what = $this->descriptionWhat;
                $targets = $this->descriptionTargets;
+
                return array(
                        "api.php?action=query&list={$name}&{$p}from=B&{$p}prop=ids|title"
-                                       => "List $targets with page ids they are from, including missing ones. Start at B",
+                               => "List $targets with page ids they are from, including missing ones. Start at B",
                        "api.php?action=query&list={$name}&{$p}unique=&{$p}from=B"
-                                       => "List unique $targets",
+                               => "List unique $targets",
                        "api.php?action=query&generator={$name}&g{$p}unique=&g{$p}from=B"
-                                       => "Gets all $targets, marking the missing ones",
+                               => "Gets all $targets, marking the missing ones",
                        "api.php?action=query&generator={$name}&g{$p}from=B"
-                                       => "Gets pages containing the {$what}s",
+                               => "Gets pages containing the {$what}s",
                );
        }
 
        public function getHelpUrls() {
                $name = ucfirst( $this->getModuleName() );
+
                return "https://www.mediawiki.org/wiki/API:{$name}";
        }
 }
index d47c7b7..6b1d5a2 100644 (file)
@@ -241,10 +241,10 @@ class ApiQueryAllMessages extends ApiQueryBase {
                        'messages' => 'Which messages to output. "*" (default) means all messages',
                        'prop' => 'Which properties to get',
                        'enableparser' => array( 'Set to enable parser, will preprocess the wikitext of message',
-                                                       'Will substitute magic words, handle templates etc.' ),
+                               'Will substitute magic words, handle templates etc.' ),
                        'nocontent' => 'If set, do not include the content of the messages in the output.',
                        'includelocal' => array( "Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page.",
-                                                       "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js",
+                               "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js",
                        ),
                        'title' => 'Page name to use as context when parsing message (for enableparser option)',
                        'args' => 'Arguments to be substituted into message',
index d95980c..3c24405 100644 (file)
@@ -145,7 +145,6 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                        }
 
                        $this->addOption( 'DISTINCT' );
-
                } elseif ( isset( $params['prlevel'] ) ) {
                        $this->dieUsage( 'prlevel may not be used without prtype', 'params' );
                }
@@ -186,7 +185,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
                $count = 0;
                $result = $this->getResult();
                foreach ( $res as $row ) {
-                       if ( ++ $count > $limit ) {
+                       if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                $this->setContinueEnumParameter( 'continue', $row->page_title );
                                break;
@@ -291,6 +290,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'from' => 'The page title to start enumerating from',
                        'continue' => 'When more results are available, use this to continue',
index 1948a51..68f2487 100644 (file)
@@ -90,6 +90,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        // no group with the given right(s) exists, no need for a query
                        if ( !count( $groups ) ) {
                                $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), '' );
+
                                return;
                        }
 
@@ -111,7 +112,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        // Filter only users that belong to a given group
                        $this->addTables( 'user_groups', 'ug1' );
                        $this->addJoinConds( array( 'ug1' => array( 'INNER JOIN', array( 'ug1.ug_user=user_id',
-                                       'ug1.ug_group' => $params['group'] ) ) ) );
+                               'ug1.ug_group' => $params['group'] ) ) ) );
                }
 
                if ( !is_null( $params['excludegroup'] ) && count( $params['excludegroup'] ) ) {
@@ -126,8 +127,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        }
                        $this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN',
                                array_merge( array( 'ug1.ug_user=user_id' ), $exclude )
-                               )
-                       ) );
+                       ) ) );
                        $this->addWhere( 'ug1.ug_user IS NULL' );
                }
 
@@ -201,7 +201,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                // Save the last pass's user data
                                if ( is_array( $lastUserData ) ) {
                                        $fit = $result->addValue( array( 'query', $this->getModuleName() ),
-                                                       null, $lastUserData );
+                                               null, $lastUserData );
 
                                        $lastUserData = null;
 
@@ -312,6 +312,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
 
        public function getAllowedParams() {
                $userGroups = User::getAllGroups();
+
                return array(
                        'from' => null,
                        'to' => null,
@@ -360,6 +361,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
 
        public function getParamDescription() {
                global $wgActiveUserDays;
+
                return array(
                        'from' => 'The user name to start enumerating from',
                        'to' => 'The user name to stop enumerating at',
@@ -376,7 +378,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                ' rights         - Lists rights that the user has',
                                ' editcount      - Adds the edit count of the user',
                                ' registration   - Adds the timestamp of when the user registered if available (may be blank)',
-                               ),
+                       ),
                        'limit' => 'How many total user names to return',
                        'witheditsonly' => 'Only list users who have made edits',
                        'activeusers' => "Only list users active in the last {$wgActiveUserDays} days(s)"
index 2d1089a..238c8e8 100644 (file)
@@ -193,7 +193,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        $redirNs = $t->getNamespace();
                        $redirDBkey = $t->getDBkey();
                        $titleWhere[] = "{$this->bl_title} = " . $db->addQuotes( $redirDBkey ) .
-                                       ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
+                               ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
                        $allRedirNs[] = $redirNs;
                        $allRedirDBkey[] = $redirDBkey;
                }
@@ -209,14 +209,14 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        $from = $this->redirID;
                        if ( $this->hasNS ) {
                                $this->addWhere( "{$this->bl_ns} $op $ns OR " .
-                                               "({$this->bl_ns} = $ns AND " .
-                                               "({$this->bl_title} $op $title OR " .
-                                               "({$this->bl_title} = $title AND " .
-                                               "{$this->bl_from} $op= $from)))" );
+                                       "({$this->bl_ns} = $ns AND " .
+                                       "({$this->bl_title} $op $title OR " .
+                                       "({$this->bl_title} = $title AND " .
+                                       "{$this->bl_from} $op= $from)))" );
                        } else {
                                $this->addWhere( "{$this->bl_title} $op $title OR " .
-                                               "({$this->bl_title} = $title AND " .
-                                               "{$this->bl_from} $op= $from)" );
+                                       "({$this->bl_title} = $title AND " .
+                                       "{$this->bl_from} $op= $from)" );
                        }
                }
                if ( $this->params['filterredir'] == 'redirects' ) {
@@ -268,7 +268,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $count = 0;
 
                foreach ( $res as $row ) {
-                       if ( ++ $count > $this->params['limit'] ) {
+                       if ( ++$count > $this->params['limit'] ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                // Continue string preserved in case the redirect query doesn't pass the limit
                                $this->continueStr = $this->getContinueStr( $row->page_id );
@@ -428,7 +428,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        return;
                }
                $this->redirID = $redirID;
-
        }
 
        protected function getContinueStr( $lastPageID ) {
@@ -481,6 +480,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        return $retval;
                }
                $retval['redirect'] = false;
+
                return $retval;
        }
 
@@ -499,6 +499,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                                'limit' => "How many total pages to return. If {$this->bl_code}redirect is enabled, limit applies to each level separately (which means you may get up to 2 * limit results)."
                        ) );
                }
+
                return array_merge( $retval, array(
                        'filterredir' => 'How to filter for redirects',
                        'limit' => 'How many total pages to return'
index 8668e04..c620a8f 100644 (file)
@@ -131,8 +131,10 @@ abstract class ApiQueryBase extends ApiBase {
        protected function addFieldsIf( $value, $condition ) {
                if ( $condition ) {
                        $this->addFields( $value );
+
                        return true;
                }
+
                return false;
        }
 
@@ -168,8 +170,10 @@ abstract class ApiQueryBase extends ApiBase {
        protected function addWhereIf( $value, $condition ) {
                if ( $condition ) {
                        $this->addWhere( $value );
+
                        return true;
                }
+
                return false;
        }
 
@@ -292,6 +296,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( $rowcount > $wgAPIMaxDBRows ) {
                        return false;
                }
+
                return true;
        }
 
@@ -332,6 +337,7 @@ abstract class ApiQueryBase extends ApiBase {
        protected function addPageSubItems( $pageId, $data ) {
                $result = $this->getResult();
                $result->setIndexedTagName( $data, $this->getModulePrefix() );
+
                return $result->addValue( array( 'query', 'pages', intval( $pageId ) ),
                        $this->getModuleName(),
                        $data );
@@ -356,7 +362,8 @@ abstract class ApiQueryBase extends ApiBase {
                        return false;
                }
                $result->setIndexedTagName_internal( array( 'query', 'pages', $pageId,
-                               $this->getModuleName() ), $elemname );
+                       $this->getModuleName() ), $elemname );
+
                return true;
        }
 
@@ -382,6 +389,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( is_null( $this->mDb ) ) {
                        $this->mDb = $this->getQuery()->getDB();
                }
+
                return $this->mDb;
        }
 
@@ -419,6 +427,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( !$t ) {
                        $this->dieUsageMsg( array( 'invalidtitle', $title ) );
                }
+
                return $t->getPrefixedDBkey();
        }
 
@@ -437,6 +446,7 @@ abstract class ApiQueryBase extends ApiBase {
                if ( !$t ) {
                        $this->dieUsageMsg( array( 'invalidtitle', $key ) );
                }
+
                return $t->getPrefixedText();
        }
 
@@ -446,7 +456,7 @@ abstract class ApiQueryBase extends ApiBase {
         * @return string Title part with underscores
         */
        public function titlePartToKey( $titlePart ) {
-               return substr( $this->titleToKey( $titlePart . 'x' ), 0, - 1 );
+               return substr( $this->titleToKey( $titlePart . 'x' ), 0, -1 );
        }
 
        /**
@@ -455,7 +465,7 @@ abstract class ApiQueryBase extends ApiBase {
         * @return string Key part with underscores
         */
        public function keyPartToTitle( $keyPart ) {
-               return substr( $this->keyToTitle( $keyPart . 'x' ), 0, - 1 );
+               return substr( $this->keyToTitle( $keyPart . 'x' ), 0, -1 );
        }
 
        /**
@@ -467,10 +477,10 @@ abstract class ApiQueryBase extends ApiBase {
         */
        public function getDirectionDescription( $p = '', $extraDirText = '' ) {
                return array(
-                               "In which direction to enumerate{$extraDirText}",
-                               " newer          - List oldest first. Note: {$p}start has to be before {$p}end.",
-                               " older          - List newest first (default). Note: {$p}start has to be later than {$p}end.",
-                       );
+                       "In which direction to enumerate{$extraDirText}",
+                       " newer          - List oldest first. Note: {$p}start has to be before {$p}end.",
+                       " older          - List newest first (default). Note: {$p}start has to be later than {$p}end.",
+               );
        }
 
        /**
@@ -491,6 +501,7 @@ abstract class ApiQueryBase extends ApiBase {
                        }
 
                        $likeQuery = LinkFilter::keepOneWildcard( $likeQuery );
+
                        return 'el_index ' . $db->buildLike( $likeQuery );
                } elseif ( !is_null( $protocol ) ) {
                        return 'el_index ' . $db->buildLike( "$protocol", $db->anyString() );
@@ -553,6 +564,7 @@ abstract class ApiQueryBase extends ApiBase {
                        array( 'invalidtitle', 'title' ),
                        array( 'invalidtitle', 'key' ),
                ) );
+
                return $errors;
        }
 }
@@ -587,6 +599,7 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase {
                if ( $this->mGeneratorPageSet !== null ) {
                        return $this->mGeneratorPageSet;
                }
+
                return parent::getPageSet();
        }
 
index e3c27f5..8dad635 100644 (file)
@@ -72,8 +72,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                $this->addFieldsIf( 'ipb_reason', $fld_reason );
                $this->addFieldsIf( array( 'ipb_range_start', 'ipb_range_end' ), $fld_range );
                $this->addFieldsIf( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock',
-                                                                       'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ),
-                                                       $fld_flags );
+                       'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ),
+                       $fld_flags );
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
                $this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
@@ -134,9 +134,9 @@ class ApiQueryBlocks extends ApiQueryBase {
 
                        /* Check for conflicting parameters. */
                        if ( ( isset( $show['account'] ) && isset( $show['!account'] ) )
-                                       || ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
-                                       || ( isset( $show['range'] ) && isset( $show['!range'] ) )
-                                       || ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
+                               || ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
+                               || ( isset( $show['range'] ) && isset( $show['!range'] ) )
+                               || ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
                        ) {
                                $this->dieUsageMsg( 'show' );
                        }
@@ -309,6 +309,7 @@ class ApiQueryBlocks extends ApiQueryBase {
        public function getParamDescription() {
                global $wgBlockCIDRLimit;
                $p = $this->getModulePrefix();
+
                return array(
                        'start' => 'The timestamp to start enumerating from',
                        'end' => 'The timestamp to stop enumerating at',
@@ -402,6 +403,7 @@ class ApiQueryBlocks extends ApiQueryBase {
 
        public function getPossibleErrors() {
                global $wgBlockCIDRLimit;
+
                return array_merge( parent::getPossibleErrors(),
                        $this->getRequireOnlyOneParameterErrorMessages( array( 'users', 'ip' ) ),
                        array(
index 5d714f5..e62305a 100644 (file)
@@ -98,8 +98,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) ) {
                        $this->dieUsageMsg( 'show' );
                }
-               if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) )
-               {
+               if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) ) {
                        $this->addOption( 'STRAIGHT_JOIN' );
                        $this->addTables( array( 'page', 'page_props' ) );
                        $this->addFieldsIf( 'pp_propname', isset( $prop['hidden'] ) );
@@ -126,9 +125,9 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                        $this->addOption( 'ORDER BY', 'cl_to' . $sort );
                } else {
                        $this->addOption( 'ORDER BY', array(
-                                               'cl_from' . $sort,
-                                               'cl_to' . $sort
-                       ));
+                               'cl_from' . $sort,
+                               'cl_to' . $sort
+                       ) );
                }
 
                $res = $this->select( __METHOD__ );
index a889272..4e78f02 100644 (file)
@@ -45,7 +45,7 @@ class ApiQueryCategoryInfo extends ApiQueryBase {
                $categories = $alltitles[NS_CATEGORY];
 
                $titles = $this->getPageSet()->getGoodTitles() +
-                                       $this->getPageSet()->getMissingTitles();
+                       $this->getPageSet()->getMissingTitles();
                $cattitles = array();
                foreach ( $categories as $c ) {
                        /** @var $t Title */
index 704d108..9dc7a32 100644 (file)
@@ -180,7 +180,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                $result = $this->getResult();
                $count = 0;
                foreach ( $rows as $row ) {
-                       if ( ++ $count > $limit ) {
+                       if ( ++$count > $limit ) {
                                // We've reached the one extra which shows that there are additional pages to be had. Stop here...
                                // TODO: Security issue - if the user has no right to view next title, it will still be shown
                                if ( $params['sort'] == 'timestamp' ) {
@@ -224,7 +224,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
                                }
                                $fit = $result->addValue( array( 'query', $this->getModuleName() ),
-                                               null, $vals );
+                                       null, $vals );
                                if ( !$fit ) {
                                        if ( $params['sort'] == 'timestamp' ) {
                                                $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
@@ -357,6 +357,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                "Note that you can use {$p}type=subcat or {$p}type=file instead of {$p}namespace=14 or 6.",
                        );
                }
+
                return $desc;
        }