From: Siebrand Mazeland Date: Thu, 14 Nov 2013 18:03:09 +0000 (+0100) Subject: Fix CodeSniffer errors and warnings (final round for API classes) X-Git-Tag: 1.31.0-rc.0~18117 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=1707a7995e2361c89bd973a8fad9165803d8c935;p=lhc%2Fweb%2Fwiklou.git Fix CodeSniffer errors and warnings (final round for API classes) Change-Id: I97bf36ebef254818dc17378a06405b681ad19c59 --- diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index cfbc095096..6c4bb08634 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -112,7 +112,8 @@ class ApiPageSet extends ApiBase { /** * Populate the PageSet from the request parameters. - * @param bool $isDryRun If true, instantiates generator, but only to mark relevant parameters as used + * @param bool $isDryRun If true, instantiates generator, but only to mark + * relevant parameters as used */ private function executeInternal( $isDryRun ) { $this->profileIn(); @@ -200,8 +201,9 @@ class ApiPageSet extends ApiBase { break; case 'revids': if ( $this->mResolveRedirects ) { - $this->setWarning( 'Redirect resolution cannot be used together with the revids= parameter. ' . - 'Any redirects the revids= point to have not been resolved.' ); + $this->setWarning( 'Redirect resolution cannot be used ' . + 'together with the revids= parameter. Any redirects ' . + 'the revids= point to have not been resolved.' ); } $this->mResolveRedirects = false; $this->initFromRevIDs( $this->mParams['revids'] ); @@ -870,7 +872,12 @@ class ApiPageSet extends ApiBase { foreach ( $res as $row ) { $rdfrom = intval( $row->rd_from ); $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText(); - $to = Title::makeTitle( $row->rd_namespace, $row->rd_title, $row->rd_fragment, $row->rd_interwiki ); + $to = Title::makeTitle( + $row->rd_namespace, + $row->rd_title, + $row->rd_fragment, + $row->rd_interwiki + ); unset( $this->mPendingRedirectIDs[$rdfrom] ); if ( !$to->isExternal() && !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) { $lb->add( $row->rd_namespace, $row->rd_title ); @@ -1086,19 +1093,34 @@ class ApiPageSet extends ApiBase { 'titles' => 'A list of titles to work on', 'pageids' => 'A list of page IDs to work on', 'revids' => 'A list of revision IDs to work on', - 'generator' => array( 'Get the list of pages to work on by executing the specified query module.', - 'NOTE: generator parameter names must be prefixed with a \'g\', see examples' ), + 'generator' => array( + 'Get the list of pages to work on by executing the specified query module.', + 'NOTE: generator parameter names must be prefixed with a \'g\', see examples' + ), 'redirects' => 'Automatically resolve redirects', - 'converttitles' => array( 'Convert titles to other variants if necessary. Only works if the wiki\'s content language supports variant conversion.', - 'Languages that support variant conversion include ' . implode( ', ', LanguageConverter::$languagesWithVariants ) ), + 'converttitles' => array( + 'Convert titles to other variants if necessary. Only works if ' . + 'the wiki\'s content language supports variant conversion.', + 'Languages that support variant conversion include ' . + implode( ', ', LanguageConverter::$languagesWithVariants ) + ), ); } public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'multisource', 'info' => "Cannot use 'pageids' at the same time as 'dataSource'" ), - array( 'code' => 'multisource', 'info' => "Cannot use 'revids' at the same time as 'dataSource'" ), - array( 'code' => 'badgenerator', 'info' => 'Module $generatorName cannot be used as a generator' ), + array( + 'code' => 'multisource', + 'info' => "Cannot use 'pageids' at the same time as 'dataSource'" + ), + array( + 'code' => 'multisource', + 'info' => "Cannot use 'revids' at the same time as 'dataSource'" + ), + array( + 'code' => 'badgenerator', + 'info' => 'Module $generatorName cannot be used as a generator' + ), ) ); } } diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 7ecf71f3f8..2b4710aa3b 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -226,7 +226,8 @@ class ApiParamInfo extends ApiBase { if ( isset( $p[ApiBase::PARAM_TYPE] ) ) { $a['type'] = $p[ApiBase::PARAM_TYPE]; if ( is_array( $a['type'] ) ) { - $a['type'] = array_values( $a['type'] ); // to prevent sparse arrays from being serialized to JSON as objects + // To prevent sparse arrays from being serialized to JSON as objects + $a['type'] = array_values( $a['type'] ); $result->setIndexedTagName( $a['type'], 't' ); } } @@ -341,7 +342,8 @@ class ApiParamInfo extends ApiBase { 'modules' => 'List of module names (value of the action= parameter)', 'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)', 'mainmodule' => 'Get information about the main (top-level) module as well', - 'pagesetmodule' => 'Get information about the pageset module (providing titles= and friends) as well', + 'pagesetmodule' => 'Get information about the pageset module ' . + '(providing titles= and friends) as well', 'formatmodules' => 'List of format module names (value of format= parameter)', ); } diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 91a3a99fa2..3e2e5a81b5 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -60,7 +60,10 @@ class ApiParse extends ApiBase { $format = $params['contentformat']; if ( !is_null( $page ) && ( !is_null( $text ) || $titleProvided ) ) { - $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' ); + $this->dieUsage( + 'The page parameter cannot be used together with the text and title parameters', + 'params' + ); } $prop = array_flip( $params['prop'] ); @@ -76,9 +79,12 @@ class ApiParse extends ApiBase { // TODO: Does this still need $wgTitle? global $wgParser, $wgTitle; - // Currently unnecessary, code to act as a safeguard against any change in current behavior of uselang + // Currently unnecessary, code to act as a safeguard against any change + // in current behavior of uselang $oldLang = null; - if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) { + if ( isset( $params['uselang'] ) + && $params['uselang'] != $this->getContext()->getLanguage()->getCode() + ) { $oldLang = $this->getContext()->getLanguage(); // Backup language $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) ); } @@ -250,7 +256,10 @@ class ApiParse extends ApiBase { if ( !is_null( $params['summary'] ) ) { $result_array['parsedsummary'] = array(); - ApiResult::setContent( $result_array['parsedsummary'], Linker::formatComment( $params['summary'], $titleObj ) ); + ApiResult::setContent( + $result_array['parsedsummary'], + Linker::formatComment( $params['summary'], $titleObj ) + ); } if ( isset( $prop['langlinks'] ) || isset( $prop['languageshtml'] ) ) { @@ -322,7 +331,10 @@ class ApiParse extends ApiBase { if ( isset( $prop['headhtml'] ) ) { $result_array['headhtml'] = array(); - ApiResult::setContent( $result_array['headhtml'], $context->getOutput()->headElement( $context->getSkin() ) ); + ApiResult::setContent( + $result_array['headhtml'], + $context->getOutput()->headElement( $context->getSkin() ) + ); } } @@ -512,7 +524,8 @@ class ApiParse extends ApiBase { } /** - * @deprecated since 1.18 No modern skin generates language links this way, please use language links + * @deprecated since 1.18 No modern skin generates language links this way, + * please use language links * data to generate your own HTML. * @param $languages array * @return string @@ -526,7 +539,8 @@ class ApiParse extends ApiBase { return ''; } - $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() ); + $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . + wfMessage( 'colon-separator' )->text() ); $langs = array(); foreach ( $languages as $l ) { @@ -642,7 +656,8 @@ class ApiParse extends ApiBase { ApiBase::PARAM_TYPE => 'integer', ), 'prop' => array( - ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties', + ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|' . + 'images|externallinks|sections|revid|displaytitle|iwlinks|properties', ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array( 'text', @@ -751,7 +766,8 @@ class ApiParse extends ApiBase { return array( 'Parses content and returns parser output', - 'See the various prop-Modules of action=query to get information from the current version of a page', + 'See the various prop-Modules of action=query to get information from the current' . + 'version of a page', 'There are several ways to specify the text to parse:', "1) Specify a page or revision, using {$p}page, {$p}pageid, or {$p}oldid.", "2) Specify content explicitly, using {$p}text, {$p}title, and {$p}contentmodel.", @@ -761,15 +777,24 @@ class ApiParse extends ApiBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters' ), + array( + 'code' => 'params', + 'info' => 'The page parameter cannot be used together with the text and title parameters' + ), array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ), - array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions' ), + array( + 'code' => 'permissiondenied', + 'info' => 'You don\'t have permission to view deleted revisions' + ), array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ), array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ), array( 'nosuchpageid' ), array( 'invalidtitle', 'title' ), array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ), - array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ), + array( + 'code' => 'notwikitext', + 'info' => 'The requested operation is only supported on wikitext content.' + ), array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ), ) ); } @@ -778,7 +803,8 @@ class ApiParse extends ApiBase { return array( 'api.php?action=parse&page=Project:Sandbox' => 'Parse a page', 'api.php?action=parse&text={{Project:Sandbox}}' => 'Parse wikitext', - 'api.php?action=parse&text={{PAGENAME}}&title=Test' => 'Parse wikitext, specifying the page title', + 'api.php?action=parse&text={{PAGENAME}}&title=Test' + => 'Parse wikitext, specifying the page title', 'api.php?action=parse&summary=Some+[[link]]&prop=' => 'Parse a summary', ); } diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 25727d056d..80c76b30a7 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -28,7 +28,6 @@ * @ingroup API */ class ApiProtect extends ApiBase { - public function execute() { global $wgRestrictionLevels; $params = $this->extractRequestParams(); @@ -47,7 +46,11 @@ class ApiProtect extends ApiBase { if ( count( $expiry ) == 1 ) { $expiry = array_fill( 0, count( $params['protections'] ), $expiry[0] ); } else { - $this->dieUsageMsg( array( 'toofewexpiries', count( $expiry ), count( $params['protections'] ) ) ); + $this->dieUsageMsg( array( + 'toofewexpiries', + count( $expiry ), + count( $params['protections'] ) + ) ); } } @@ -100,7 +103,13 @@ class ApiProtect extends ApiBase { $watch = $params['watch'] ? 'watch' : $params['watchlist']; $this->setWatch( $watch, $titleObj, 'watchdefault' ); - $status = $pageObj->doUpdateRestrictions( $protections, $expiryarray, $cascade, $params['reason'], $this->getUser() ); + $status = $pageObj->doUpdateRestrictions( + $protections, + $expiryarray, + $cascade, + $params['reason'], + $this->getUser() + ); if ( !$status->isOK() ) { $this->dieStatus( $status ); @@ -173,13 +182,19 @@ class ApiProtect extends ApiBase { 'pageid' => "ID of the page you want to (un)protect. Cannot be used together with {$p}title", 'token' => 'A protect token previously retrieved through prop=info', 'protections' => 'List of protection levels, formatted action=group (e.g. edit=sysop)', - 'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.', - 'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.' ), + 'expiry' => array( + 'Expiry timestamps. If only one timestamp is ' . + 'set, it\'ll be used for all protections.', + 'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.' + ), 'reason' => 'Reason for (un)protecting', - 'cascade' => array( 'Enable cascading protection (i.e. protect pages included in this page)', - 'Ignored if not all protection levels are \'sysop\' or \'protect\'' ), + 'cascade' => array( + 'Enable cascading protection (i.e. protect pages included in this page)', + 'Ignored if not all protection levels are \'sysop\' or \'protect\'' + ), 'watch' => 'If set, add the page being (un)protected to your watchlist', - 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', + 'watchlist' => 'Unconditionally add or remove the page from your ' . + 'watchlist, use preferences or do not change watch', ); } @@ -222,8 +237,10 @@ class ApiProtect extends ApiBase { public function getExamples() { return array( - 'api.php?action=protect&title=Main%20Page&token=123ABC&protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never', - 'api.php?action=protect&title=Main%20Page&token=123ABC&protections=edit=all|move=all&reason=Lifting%20restrictions' + 'api.php?action=protect&title=Main%20Page&token=123ABC&' . + 'protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never', + 'api.php?action=protect&title=Main%20Page&token=123ABC&' . + 'protections=edit=all|move=all&reason=Lifting%20restrictions' ); } diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 4c7981ee14..c0dd808863 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -30,7 +30,6 @@ * @ingroup API */ class ApiPurge extends ApiBase { - private $mPageSet; /** @@ -91,7 +90,12 @@ class ApiPurge extends ApiBase { # Parse content; note that HTML generation is only needed if we want to cache the result. $content = $page->getContent( Revision::RAW ); - $p_result = $content->getParserOutput( $title, $page->getLatest(), $popts, $wgEnableParserCache ); + $p_result = $content->getParserOutput( + $title, + $page->getLatest(), + $popts, + $wgEnableParserCache + ); # Update the links tables $updates = $content->getSecondaryDataUpdates( diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index ea57196fef..79a3b051b1 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -708,25 +708,32 @@ class ApiQuery extends ApiBase { public function getParamDescription() { return $this->getPageSet()->getFinalParamDescription() + array( - 'prop' => 'Which properties to get for the titles/revisions/pageids. Module help is available below', + 'prop' => 'Which properties to get for the titles/revisions/pageids. ' . + 'Module help is available below', 'list' => 'Which lists to get. Module help is available below', 'meta' => 'Which metadata to get about the site. Module help is available below', 'indexpageids' => 'Include an additional pageids section listing all returned page IDs', 'export' => 'Export the current revisions of all given or generated pages', - 'exportnowrap' => 'Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export', + 'exportnowrap' => 'Return the export XML without wrapping it in an '. + 'XML result (same format as Special:Export). Can only be used with export', 'iwurl' => 'Whether to get the full URL if the title is an interwiki link', 'continue' => array( - 'When present, formats query-continue as key-value pairs that should simply be merged into the original request.', + 'When present, formats query-continue as key-value pairs that ' . + 'should simply be merged into the original request.', 'This parameter must be set to an empty string in the initial query.', - 'This parameter is recommended for all new development, and will be made default in the next API version.' ), + 'This parameter is recommended for all new development, and ' . + 'will be made default in the next API version.' + ), ); } public function getDescription() { return array( - 'Query API module allows applications to get needed pieces of data from the MediaWiki databases,', + 'Query API module allows applications to get needed pieces of data ' . + 'from the MediaWiki databases,', 'and is loosely based on the old query.php interface.', - 'All data modifications will first have to use query to acquire a token to prevent abuse from malicious sites' + 'All data modifications will first have to use query to acquire a ' . + 'token to prevent abuse from malicious sites' ); } @@ -739,7 +746,8 @@ class ApiQuery extends ApiBase { public function getExamples() { return array( - 'api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user|comment&continue=', + 'api.php?action=query&prop=revisions&meta=siteinfo&' . + 'titles=Main%20Page&rvprop=user|comment&continue=', 'api.php?action=query&generator=allpages&gapprefix=API/&prop=revisions&continue=', ); } diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index 5ef71f0b31..d0ab59e98c 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -80,7 +80,8 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { } if ( isset( $params['prefix'] ) ) { - $this->addWhere( 'cat_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( 'cat_title' . + $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); @@ -110,7 +111,8 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $count = 0; foreach ( $res as $row ) { if ( ++$count > $params['limit'] ) { - // We've reached the one extra which shows that there are additional cats to be had. Stop here... + // We've reached the one extra which shows that there are + // additional cats to be had. Stop here... $this->setContinueEnumParameter( 'continue', $row->cat_title ); break; } diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 5baee8d71b..9f97cac9ed 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -32,7 +32,6 @@ * @ingroup API */ class ApiQueryAllImages extends ApiQueryGeneratorBase { - protected $mRepo; public function __construct( $query, $moduleName ) { @@ -65,7 +64,11 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { */ public function executeGenerator( $resultPageSet ) { if ( $resultPageSet->isResolvingRedirects() ) { - $this->dieUsage( 'Use "gaifilterredir=nonredirects" option instead of "redirects" when using allimages as a generator', 'params' ); + $this->dieUsage( + 'Use "gaifilterredir=nonredirects" option instead of "redirects" ' . + 'when using allimages as a generator', + 'params' + ); } $this->run( $resultPageSet ); @@ -78,7 +81,10 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { private function run( $resultPageSet = null ) { $repo = $this->mRepo; if ( !$repo instanceof LocalRepo ) { - $this->dieUsage( 'Local file repository does not support querying all images', 'unsupportedrepo' ); + $this->dieUsage( + 'Local file repository does not support querying all images', + 'unsupportedrepo' + ); } $prefix = $this->getModulePrefix(); @@ -103,11 +109,17 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $disallowed = array( 'start', 'end', 'user' ); foreach ( $disallowed as $pname ) { if ( isset( $params[$pname] ) ) { - $this->dieUsage( "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=timestamp", 'badparams' ); + $this->dieUsage( + "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=timestamp", + 'badparams' + ); } } if ( $params['filterbots'] != 'all' ) { - $this->dieUsage( "Parameter '{$prefix}filterbots' can only be used with {$prefix}sort=timestamp", 'badparams' ); + $this->dieUsage( + "Parameter '{$prefix}filterbots' can only be used with {$prefix}sort=timestamp", + 'badparams' + ); } // Pagination @@ -125,23 +137,36 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $this->addWhereRange( 'img_name', ( $ascendingOrder ? 'newer' : 'older' ), $from, $to ); if ( isset( $params['prefix'] ) ) { - $this->addWhere( 'img_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( 'img_name' . + $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } } else { // Check mutually exclusive params $disallowed = array( 'from', 'to', 'prefix' ); foreach ( $disallowed as $pname ) { if ( isset( $params[$pname] ) ) { - $this->dieUsage( "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=name", 'badparams' ); + $this->dieUsage( + "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=name", + 'badparams' + ); } } if ( !is_null( $params['user'] ) && $params['filterbots'] != 'all' ) { - // Since filterbots checks if each user has the bot right, it doesn't make sense to use it with user - $this->dieUsage( "Parameters '{$prefix}user' and '{$prefix}filterbots' cannot be used together", 'badparams' ); + // Since filterbots checks if each user has the bot right, it + // doesn't make sense to use it with user + $this->dieUsage( + "Parameters '{$prefix}user' and '{$prefix}filterbots' cannot be used together", + 'badparams' + ); } // Pagination - $this->addTimestampWhereRange( 'img_timestamp', ( $ascendingOrder ? 'newer' : 'older' ), $params['start'], $params['end'] ); + $this->addTimestampWhereRange( + 'img_timestamp', + $ascendingOrder ? 'newer' : 'older', + $params['start'], + $params['end'] + ); // Image filters if ( !is_null( $params['user'] ) ) { @@ -223,7 +248,8 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $result = $this->getResult(); foreach ( $res as $row ) { if ( ++$count > $limit ) { - // We've reached the one extra which shows that there are additional pages to be had. Stop here... + // We've reached the one extra which shows that there are + // additional pages to be had. Stop here... if ( $params['sort'] == 'name' ) { $this->setContinueEnumParameter( 'continue', $row->img_name ); } else { @@ -336,13 +362,16 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { 'start' => "The timestamp to start enumerating from. Can only be used with {$p}sort=timestamp", 'end' => "The timestamp to end enumerating. Can only be used with {$p}sort=timestamp", 'prop' => ApiQueryImageInfo::getPropertyDescriptions( $this->propertyFilter ), - 'prefix' => "Search for all image titles that begin with this value. Can only be used with {$p}sort=name", + 'prefix' => "Search for all image titles that begin with this " . + "value. Can only be used with {$p}sort=name", 'minsize' => 'Limit to images with at least this many bytes', 'maxsize' => 'Limit to images with at most this many bytes', 'sha1' => "SHA1 hash of image. Overrides {$p}sha1base36", 'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki)', - 'user' => "Only return files uploaded by this user. Can only be used with {$p}sort=timestamp. Cannot be used together with {$p}filterbots", - 'filterbots' => "How to filter files uploaded by bots. Can only be used with {$p}sort=timestamp. Cannot be used together with {$p}user", + 'user' => "Only return files uploaded by this user. Can only be used " . + "with {$p}sort=timestamp. Cannot be used together with {$p}filterbots", + 'filterbots' => "How to filter files uploaded by bots. Can only be " . + "used with {$p}sort=timestamp. Cannot be used together with {$p}user", 'mime' => 'What MIME type to search for. e.g. image/jpeg. Disabled in Miser Mode', 'limit' => 'How many images in total to return', ); @@ -371,19 +400,52 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $p = $this->getModulePrefix(); return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'params', 'info' => 'Use "gaifilterredir=nonredirects" option instead of "redirects" when using allimages as a generator' ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}start' can only be used with {$p}sort=timestamp" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}end' can only be used with {$p}sort=timestamp" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}user' can only be used with {$p}sort=timestamp" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}filterbots' can only be used with {$p}sort=timestamp" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}from' can only be used with {$p}sort=name" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}to' can only be used with {$p}sort=name" ), - array( 'code' => 'badparams', 'info' => "Parameter'{$p}prefix' can only be used with {$p}sort=name" ), - array( 'code' => 'badparams', 'info' => "Parameters '{$p}user' and '{$p}filterbots' cannot be used together" ), - array( 'code' => 'unsupportedrepo', 'info' => 'Local file repository does not support querying all images' ), + array( + 'code' => 'params', + 'info' => 'Use "gaifilterredir=nonredirects" option instead ' . + 'of "redirects" when using allimages as a generator' + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}start' can only be used with {$p}sort=timestamp" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}end' can only be used with {$p}sort=timestamp" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}user' can only be used with {$p}sort=timestamp" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}filterbots' can only be used with {$p}sort=timestamp" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}from' can only be used with {$p}sort=name" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}to' can only be used with {$p}sort=name" + ), + array( + 'code' => 'badparams', + 'info' => "Parameter'{$p}prefix' can only be used with {$p}sort=name" + ), + array( + 'code' => 'badparams', + 'info' => "Parameters '{$p}user' and '{$p}filterbots' cannot be used together" + ), + array( + 'code' => 'unsupportedrepo', + 'info' => 'Local file repository does not support querying all images' ), array( 'code' => 'mimesearchdisabled', 'info' => 'MIME search disabled in Miser Mode' ), array( 'code' => 'invalidsha1hash', 'info' => 'The SHA1 hash provided is not valid' ), - array( 'code' => 'invalidsha1base36hash', 'info' => 'The SHA1Base36 hash provided is not valid' ), + array( + 'code' => 'invalidsha1base36hash', + 'info' => 'The SHA1Base36 hash provided is not valid' + ), ) ); } @@ -393,11 +455,13 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { 'Simple Use', 'Show a list of files starting at the letter "B"', ), - 'api.php?action=query&list=allimages&aiprop=user|timestamp|url&aisort=timestamp&aidir=older' => array( + 'api.php?action=query&list=allimages&aiprop=user|timestamp|url&' . + 'aisort=timestamp&aidir=older' => array( 'Simple Use', 'Show a list of recently uploaded files similar to Special:NewFiles', ), - 'api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo' => array( + 'api.php?action=query&generator=allimages&gailimit=4&' . + 'gaifrom=T&prop=imageinfo' => array( 'Using as Generator', 'Show info about 4 files starting at the letter "T"', ), diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 47f45054c0..ff53d0f46a 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -54,7 +54,8 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $this->dfltNamespace = NS_TEMPLATE; $this->hasNamespace = true; $this->indexTag = 't'; - $this->description = 'List all transclusions (pages embedded using {{x}}), including non-existing'; + $this->description = + 'List all transclusions (pages embedded using {{x}}), including non-existing'; $this->descriptionWhat = 'transclusion'; $this->descriptionTargets = 'transcluded titles'; $this->descriptionLinking = 'transcluding'; @@ -113,8 +114,10 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if ( $params['unique'] ) { if ( $fld_ids ) { $this->dieUsage( - "{$this->getModuleName()} cannot return corresponding page ids in unique {$this->descriptionWhat}s mode", - 'params' ); + "{$this->getModuleName()} cannot return corresponding page " . + "ids in unique {$this->descriptionWhat}s mode", + 'params' + ); } $this->addOption( 'DISTINCT' ); } @@ -145,12 +148,15 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { } // 'continue' always overrides 'from' - $from = ( $continue || is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); + $from = $continue || is_null( $params['from'] ) + ? null + : $this->titlePartToKey( $params['from'] ); $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); $this->addWhereRange( $pfx . $fieldTitle, 'newer', $from, $to ); if ( isset( $params['prefix'] ) ) { - $this->addWhere( $pfx . $fieldTitle . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( $pfx . $fieldTitle . + $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } $this->addFields( array( 'pl_title' => $pfx . $fieldTitle ) ); @@ -178,7 +184,8 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $result = $this->getResult(); foreach ( $res as $row ) { if ( ++$count > $limit ) { - // We've reached the one extra which shows that there are additional pages to be had. Stop here... + // 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 ); } else { @@ -313,7 +320,10 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $what = $this->descriptionWhat; return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$what}s mode" ), + array( + 'code' => 'params', + 'info' => "{$m} cannot return corresponding page ids in unique {$what}s mode" + ), ) ); } diff --git a/includes/api/ApiQueryAllPages.php b/includes/api/ApiQueryAllPages.php index 3c24405517..363d6578f2 100644 --- a/includes/api/ApiQueryAllPages.php +++ b/includes/api/ApiQueryAllPages.php @@ -49,7 +49,11 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { */ public function executeGenerator( $resultPageSet ) { if ( $resultPageSet->isResolvingRedirects() ) { - $this->dieUsage( 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator', 'params' ); + $this->dieUsage( + 'Use "gapfilterredir=nonredirects" option instead of "redirects" ' . + 'when using allpages as a generator', + 'params' + ); } $this->run( $resultPageSet ); @@ -88,7 +92,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { $this->addWhereRange( 'page_title', $dir, $from, $to ); if ( isset( $params['prefix'] ) ) { - $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( 'page_title' . + $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } if ( is_null( $resultPageSet ) ) { @@ -186,7 +191,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { $result = $this->getResult(); foreach ( $res as $row ) { if ( ++$count > $limit ) { - // We've reached the one extra which shows that there are additional pages to be had. Stop here... + // 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; } @@ -303,7 +309,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { 'maxsize' => 'Limit to pages with at most this many bytes', 'prtype' => 'Limit to protected pages only', 'prlevel' => "The protection level (must be used with {$p}prtype= parameter)", - 'prfiltercascade' => "Filter protections based on cascadingness (ignored when {$p}prtype isn't set)", + 'prfiltercascade' + => "Filter protections based on cascadingness (ignored when {$p}prtype isn't set)", 'filterlanglinks' => array( 'Filter based on whether a page has langlinks', 'Note that this may not consider langlinks added by extensions.', @@ -334,7 +341,11 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'params', 'info' => 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator' ), + array( + 'code' => 'params', + 'info' => 'Use "gapfilterredir=nonredirects" option instead of ' . + '"redirects" when using allpages as a generator' + ), array( 'code' => 'params', 'info' => 'prlevel may not be used without prtype' ), ) ); } @@ -349,9 +360,9 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { 'Using as Generator', 'Show info about 4 pages starting at the letter "T"', ), - 'api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content' => array( - 'Show content of first 2 non-redirect pages beginning at "Re"', - ) + 'api.php?action=query&generator=allpages&gaplimit=2&' . + 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content' + => array( 'Show content of first 2 non-redirect pages beginning at "Re"' ) ); }