From: Siebrand Mazeland Date: Thu, 14 Nov 2013 13:00:02 +0000 (+0100) Subject: I'm in your API classes updating your formatting X-Git-Tag: 1.31.0-rc.0~18140^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=dadbe238100d566b07dca3b3560fbe15f2b8afc1;p=lhc%2Fweb%2Fwiklou.git I'm in your API classes updating your formatting Change-Id: I6087573dfdc6edcd63062508056ebcf3502e03f2 --- diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 415288ef79..4be1594311 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -41,8 +41,8 @@ class ApiQueryRevisions extends ApiQueryBase { } private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false, $fld_sha1 = false, - $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false, - $fld_content = false, $fld_tags = false, $fld_contentmodel = false; + $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false, + $fld_content = false, $fld_tags = false, $fld_contentmodel = false; private $tokenFunctions; @@ -65,6 +65,7 @@ class ApiQueryRevisions extends ApiQueryBase { 'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' ) ); wfRunHooks( 'APIQueryRevisionsTokens', array( &$this->tokenFunctions ) ); + return $this->tokenFunctions; } @@ -79,6 +80,7 @@ class ApiQueryRevisions extends ApiQueryBase { if ( !$wgUser->isAllowed( 'rollback' ) ) { return false; } + return $wgUser->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ); } @@ -91,9 +93,9 @@ class ApiQueryRevisions extends ApiQueryBase { // Enumerating revisions on multiple pages make it extremely // difficult to manage continuations and require additional SQL indexes $enumRevMode = ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) || - !is_null( $params['limit'] ) || !is_null( $params['startid'] ) || - !is_null( $params['endid'] ) || $params['dir'] === 'newer' || - !is_null( $params['start'] ) || !is_null( $params['end'] ) ); + !is_null( $params['limit'] ) || !is_null( $params['startid'] ) || + !is_null( $params['endid'] ) || $params['dir'] === 'newer' || + !is_null( $params['start'] ) || !is_null( $params['end'] ) ); $pageSet = $this->getPageSet(); $pageCount = $pageSet->getGoodTitleCount(); @@ -119,7 +121,8 @@ class ApiQueryRevisions extends ApiQueryBase { $params['diffto'] = 0; } if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 ) - && $params['diffto'] != 'prev' && $params['diffto'] != 'next' ) { + && $params['diffto'] != 'prev' && $params['diffto'] != 'next' + ) { $this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' ); } // Check whether the revision exists and is readable, @@ -349,7 +352,7 @@ class ApiQueryRevisions extends ApiQueryBase { $this->addOption( 'ORDER BY', array( 'rev_page', 'rev_id' - )); + ) ); // assumption testing -- we should never get more then $pageCount rows. $limit = $pageCount; @@ -364,7 +367,7 @@ class ApiQueryRevisions extends ApiQueryBase { $res = $this->select( __METHOD__ ); 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 ( !$enumRevMode ) { ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report @@ -518,8 +521,8 @@ class ApiQueryRevisions extends ApiQueryBase { $vals['parsetree'] = $xml; } else { $this->setWarning( "Conversion to XML is supported for wikitext only, " . - $title->getPrefixedDBkey() . - " uses content model " . $content->getModel() ); + $title->getPrefixedDBkey() . + " uses content model " . $content->getModel() ); } } @@ -550,7 +553,7 @@ class ApiQueryRevisions extends ApiQueryBase { $name = $title->getPrefixedDBkey(); $this->dieUsage( "The requested format {$this->contentFormat} is not supported " . - "for content model $model used by $name", 'badformat' ); + "for content model $model used by $name", 'badformat' ); } $text = $content->serialize( $format ); @@ -588,12 +591,13 @@ class ApiQueryRevisions extends ApiQueryBase { $model = $title->getContentModel(); if ( $this->contentFormat - && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) { + && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) + ) { $name = $title->getPrefixedDBkey(); $this->dieUsage( "The requested format {$this->contentFormat} is not supported for " . - "content model $model used by $name", 'badformat' ); + "content model $model used by $name", 'badformat' ); } $difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat ); @@ -614,6 +618,7 @@ class ApiQueryRevisions extends ApiQueryBase { $vals['diff']['notcached'] = ''; } } + return $vals; } @@ -625,6 +630,7 @@ class ApiQueryRevisions extends ApiQueryBase { // formatComment() calls wfMessage() among other things return 'anon-public-user-private'; } + return 'public'; } @@ -700,6 +706,7 @@ class ApiQueryRevisions extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => array( 'Which properties to get for each revision:', @@ -819,17 +826,17 @@ class ApiQueryRevisions extends ApiQueryBase { return array_merge( parent::getPossibleErrors(), array( array( 'nosuchrevid', 'diffto' ), array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options ' - . '(limit, startid, endid, dirNewer, start, end).' ), + . '(limit, startid, endid, dirNewer, start, end).' ), array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, ' - . ' but the limit, startid, endid, dirNewer, user, excludeuser, ' - . 'start and end parameters may only be used on a single page.' ), + . ' but the limit, startid, endid, dirNewer, user, excludeuser, ' + . 'start and end parameters may only be used on a single page.' ), array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ), array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ), array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ), array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ), array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ), array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied ' - . ' to the page\'s content model' ), + . ' to the page\'s content model' ), ) ); } diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 36b559794a..8f094faedc 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -112,12 +112,12 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $totalhits = $matches->getTotalHits(); if ( $totalhits !== null ) { $apiResult->addValue( array( 'query', 'searchinfo' ), - 'totalhits', $totalhits ); + 'totalhits', $totalhits ); } } if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) { $apiResult->addValue( array( 'query', 'searchinfo' ), - 'suggestion', $matches->getSuggestionQuery() ); + 'suggestion', $matches->getSuggestionQuery() ); } // Add the search results to the result @@ -127,7 +127,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $result = $matches->next(); while ( $result ) { - if ( ++ $count > $limit ) { + if ( ++$count > $limit ) { // We've reached the one extra which shows that there are additional items to be had. Stop here... $this->setContinueEnumParameter( 'offset', $params['offset'] + $params['limit'] ); break; @@ -184,7 +184,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { // Add item to results and see whether it fits $fit = $apiResult->addValue( array( 'query', $this->getModuleName() ), - null, $vals ); + null, $vals ); if ( !$fit ) { $this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 ); break; @@ -198,8 +198,8 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { $apiResult->setIndexedTagName_internal( array( - 'query', $this->getModuleName() - ), 'p' ); + 'query', $this->getModuleName() + ), 'p' ); } else { $resultPageSet->populateFromTitles( $titles ); } diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ebd3fc0d1d..57eb41e7e6 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -106,7 +106,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { // Abuse siprop as a query-continue parameter // and set it to all unprocessed props $this->setContinueEnumParameter( 'prop', implode( '|', - array_diff( $params['prop'], $done ) ) ); + array_diff( $params['prop'], $done ) ) ); break; } $done[] = $p; @@ -114,9 +114,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendGeneralInfo( $property ) { - global $wgContLang, - $wgDisableLangConversion, - $wgDisableTitleConversion; + global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; $data = array(); $mainPage = Title::newMainPage(); @@ -280,6 +278,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'ns' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -303,6 +302,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { sort( $data ); $this->getResult()->setIndexedTagName( $data, 'ns' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -318,6 +318,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } } $this->getResult()->setIndexedTagName( $data, 'specialpage' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -334,6 +335,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $arr; } $this->getResult()->setIndexedTagName( $data, 'magicword' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -379,6 +381,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'iw' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -410,6 +413,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $result = $this->getResult(); $result->setIndexedTagName( $data, 'db' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -450,7 +454,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( $group == 'user' ) { $arr['number'] = SiteStats::users(); - // '*' and autopromote groups have no size } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) { $arr['number'] = SiteStats::numberInGroup( $group ); @@ -476,6 +479,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $result->setIndexedTagName( $data, 'group' ); + return $result->addValue( 'query', $property, $data ); } @@ -487,6 +491,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = array( 'ext' => $ext ); } $this->getResult()->setIndexedTagName( $data, 'fe' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -521,18 +526,19 @@ class ApiQuerySiteinfo extends ApiQueryBase { $ret['url'] = $ext['url']; } if ( isset( $ext['version'] ) ) { - $ret['version'] = $ext['version']; + $ret['version'] = $ext['version']; } elseif ( isset( $ext['svn-revision'] ) && preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/', - $ext['svn-revision'], $m ) ) - { - $ret['version'] = 'r' . $m[1]; + $ext['svn-revision'], $m ) + ) { + $ret['version'] = 'r' . $m[1]; } $data[] = $ret; } } $this->getResult()->setIndexedTagName( $data, 'ext' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -566,6 +572,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $lang; } $this->getResult()->setIndexedTagName( $data, 'lang' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -585,6 +592,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data[] = $skin; } $this->getResult()->setIndexedTagName( $data, 'skin' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -593,6 +601,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $wgParser->firstCallInit(); $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() ); $this->getResult()->setIndexedTagName( $tags, 't' ); + return $this->getResult()->addValue( 'query', $property, $tags ); } @@ -601,12 +610,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { $wgParser->firstCallInit(); $hooks = $wgParser->getFunctionHooks(); $this->getResult()->setIndexedTagName( $hooks, 'h' ); + return $this->getResult()->addValue( 'query', $property, $hooks ); } public function appendVariables( $property ) { $variables = MagicWord::getVariableIDs(); $this->getResult()->setIndexedTagName( $variables, 'v' ); + return $this->getResult()->addValue( 'query', $property, $variables ); } @@ -615,6 +626,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { // Make a copy of the global so we don't try to set the _element key of it - bug 45130 $protocols = array_values( $wgUrlProtocols ); $this->getResult()->setIndexedTagName( $protocols, 'p' ); + return $this->getResult()->addValue( 'query', $property, $protocols ); } @@ -639,6 +651,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } $this->getResult()->setIndexedTagName( $data, 'hook' ); + return $this->getResult()->addValue( 'query', $property, $data ); } @@ -687,6 +700,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => array( 'Which sysinfo properties to get:', @@ -696,14 +710,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { ' specialpagealiases - List of special page aliases', ' magicwords - List of magic words and their aliases', ' statistics - Returns site statistics', - " interwikimap - Returns interwiki map " . + ' interwikimap - Returns interwiki map ' . "(optionally filtered, (optionally localised by using {$p}inlanguagecode))", ' dbrepllag - Returns database server with the highest replication lag', ' usergroups - Returns user groups and the associated permissions', ' extensions - Returns extensions installed on the wiki', ' fileextensions - Returns list of file extensions allowed to be uploaded', ' rightsinfo - Returns wiki rights (license) information if available', - " languages - Returns a list of languages MediaWiki supports" . + ' languages - Returns a list of languages MediaWiki supports' . "(optionally localised by using {$p}inlanguagecode)", ' skins - Returns a list of all enabled skins', ' extensiontags - Returns a list of parser extension tags', diff --git a/includes/api/ApiQueryStashImageInfo.php b/includes/api/ApiQueryStashImageInfo.php index 6899375ac6..f714227257 100644 --- a/includes/api/ApiQueryStashImageInfo.php +++ b/includes/api/ApiQueryStashImageInfo.php @@ -60,7 +60,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { $result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo ); $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $modulePrefix ); } - //TODO: update exception handling here to understand current getFile exceptions + // @todo Update exception handling here to understand current getFile exceptions } catch ( UploadStashNotAvailableException $e ) { $this->dieUsage( "Session not available: " . $e->getMessage(), "nosession" ); } catch ( UploadStashFileNotFoundException $e ) { @@ -112,6 +112,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { */ public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => self::getPropertyDescriptions( $this->propertyFilter, $p ), 'filekey' => 'Key that identifies a previous upload that was stashed temporarily.', @@ -137,5 +138,4 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { 'api.php?action=query&prop=stashimageinfo&siifilekey=b34edoe3|bceffd4&siiurlwidth=120&siiprop=url', ); } - } diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php index 732df9a4ed..33116ce752 100644 --- a/includes/api/ApiQueryTags.php +++ b/includes/api/ApiQueryTags.php @@ -38,7 +38,7 @@ class ApiQueryTags extends ApiQueryBase { private $limit; private $fld_displayname = false, $fld_description = false, - $fld_hitcount = false; + $fld_hitcount = false; public function __construct( $query, $moduleName ) { parent::__construct( $query, $moduleName, 'tg' ); @@ -97,6 +97,7 @@ class ApiQueryTags extends ApiQueryBase { if ( ++$count > $this->limit ) { $this->setContinueEnumParameter( 'continue', $tagName ); + return false; } @@ -121,6 +122,7 @@ class ApiQueryTags extends ApiQueryBase { $fit = $this->result->addValue( array( 'query', $this->getModuleName() ), null, $tag ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', $tagName ); + return false; } diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 9a9be7b2e2..be08c8a490 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -37,8 +37,8 @@ class ApiQueryContributions extends ApiQueryBase { private $params, $prefixMode, $userprefix, $multiUserMode, $usernames, $parentLens; private $fld_ids = false, $fld_title = false, $fld_timestamp = false, - $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false, - $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false; + $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false, + $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false; public function execute() { // Parse some parameters @@ -100,7 +100,7 @@ class ApiQueryContributions extends ApiQueryBase { // Fetch each row 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 ( $this->multiUserMode ) { $this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) ); @@ -195,7 +195,8 @@ class ApiQueryContributions extends ApiQueryBase { if ( !is_null( $show ) ) { $show = array_flip( $show ); if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) ) - || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) { + || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) + ) { $this->dieUsageMsg( 'show' ); } @@ -220,7 +221,8 @@ class ApiQueryContributions extends ApiQueryBase { ) ); if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) || - $this->fld_patrolled ) { + $this->fld_patrolled + ) { if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); } @@ -439,6 +441,7 @@ class ApiQueryContributions extends ApiQueryBase { public function getParamDescription() { global $wgRCMaxAge; $p = $this->getModulePrefix(); + return array( 'limit' => 'The maximum number of contributions to return', 'start' => 'The start timestamp to return from', @@ -462,7 +465,7 @@ class ApiQueryContributions extends ApiQueryBase { ' tags - Lists tags for the edit', ), 'show' => array( "Show only items that meet this criteria, e.g. non minor edits only: {$p}show=!minor", - "NOTE: if {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than \$wgRCMaxAge ($wgRCMaxAge) won't be shown", ), + "NOTE: If {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than \$wgRCMaxAge ($wgRCMaxAge) won't be shown", ), 'tag' => 'Only list revisions tagged with this tag', 'toponly' => 'Only list changes which are the latest revision', ); diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 3c85ea69d5..1d7ed63ee6 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -152,6 +152,7 @@ class ApiQueryUserInfo extends ApiQueryBase { $result->setIndexedTagName( $acceptLang, 'lang' ); $vals['acceptlang'] = $acceptLang; } + return $vals; } @@ -188,6 +189,7 @@ class ApiQueryUserInfo extends ApiQueryBase { } } } + return $retval; } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index dccfee67e6..78bf24e82d 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -58,6 +58,7 @@ class ApiQueryUsers extends ApiQueryBase { 'userrights' => array( 'ApiQueryUsers', 'getUserrightsToken' ), ); wfRunHooks( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) ); + return $this->tokenFunctions; } @@ -67,6 +68,7 @@ class ApiQueryUsers extends ApiQueryBase { */ public static function getUserrightsToken( $user ) { global $wgUser; + // Since the permissions check for userrights is non-trivial, // don't bother with it here return $wgUser->getEditToken( $user->getName() ); @@ -90,10 +92,10 @@ class ApiQueryUsers extends ApiQueryBase { if ( $n === false || $n === '' ) { $vals = array( 'name' => $u, 'invalid' => '' ); $fit = $result->addValue( array( 'query', $this->getModuleName() ), - null, $vals ); + null, $vals ); if ( !$fit ) { $this->setContinueEnumParameter( 'users', - implode( '|', array_diff( $users, $done ) ) ); + implode( '|', array_diff( $users, $done ) ) ); $goodNames = array(); break; } @@ -244,10 +246,10 @@ class ApiQueryUsers extends ApiQueryBase { } $fit = $result->addValue( array( 'query', $this->getModuleName() ), - null, $data[$u] ); + null, $data[$u] ); if ( !$fit ) { $this->setContinueEnumParameter( 'users', - implode( '|', array_diff( $users, $done ) ) ); + implode( '|', array_diff( $users, $done ) ) ); break; } $done[] = $u; diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 22843f50a1..2f784f4d39 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -45,8 +45,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } private $fld_ids = false, $fld_title = false, $fld_patrol = false, $fld_flags = false, - $fld_timestamp = false, $fld_user = false, $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false, - $fld_notificationtimestamp = false, $fld_userid = false, $fld_loginfo = false; + $fld_timestamp = false, $fld_user = false, $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false, + $fld_notificationtimestamp = false, $fld_userid = false, $fld_loginfo = false; /** * @param $resultPageSet ApiPageSet @@ -121,7 +121,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { 'wl_user' => $userId, 'wl_namespace=rc_namespace', 'wl_title=rc_title' - ) ) ) ); + ) + ) ) ); $this->addWhere( array( 'rc_deleted' => 0, @@ -144,9 +145,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { /* Check for conflicting parameters. */ if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) ) - || ( isset( $show['bot'] ) && isset( $show['!bot'] ) ) - || ( isset( $show['anon'] ) && isset( $show['!anon'] ) ) - || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) + || ( isset( $show['bot'] ) && isset( $show['!bot'] ) ) + || ( isset( $show['anon'] ) && isset( $show['!anon'] ) ) + || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) { $this->dieUsageMsg( 'show' ); } @@ -194,7 +195,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $res = $this->select( __METHOD__ ); foreach ( $res as $row ) { - if ( ++ $count > $params['limit'] ) { + if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that there are additional pages to be had. Stop here... $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); break; @@ -205,7 +206,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals ); if ( !$fit ) { $this->setContinueEnumParameter( 'start', - wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); + wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) ); break; } } else { @@ -348,6 +349,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { foreach ( $type as $t ) { $retval[] = $this->parseRCType( $t ); } + return $retval; } switch ( $type ) { @@ -446,6 +448,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'allrev' => 'Include multiple revisions of the same page within given timeframe', 'start' => 'The timestamp to start enumerating from', @@ -488,6 +491,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { public function getResultProperties() { global $wgLogTypes; + return array( '' => array( 'type' => array( diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index ea4e724a0b..4d977223c2 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -91,7 +91,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { $this->addOption( 'ORDER BY', array( 'wl_namespace' . $sort, 'wl_title' . $sort - )); + ) ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); @@ -109,8 +109,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { $vals = array(); ApiQueryBase::addTitleInfo( $vals, $t ); - if ( isset( $prop['changed'] ) && !is_null( $row->wl_notificationtimestamp ) ) - { + if ( isset( $prop['changed'] ) && !is_null( $row->wl_notificationtimestamp ) ) { $vals['changed'] = wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp ); } $fit = $this->getResult()->addValue( $this->getModuleName(), null, $vals );