From d45bb99e8c41bbb973be1f75918ced000e0891ac Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 14 Nov 2013 13:53:20 +0100 Subject: [PATCH] Yet more formatting updates for yet more API classes Change-Id: Iaa1cfaaffc7c55bb7670dfbff3f063cf22434f09 --- includes/api/ApiQueryDeletedrevs.php | 11 ++++++----- includes/api/ApiQueryExtLinksUsage.php | 5 +++-- includes/api/ApiQueryExternalLinks.php | 1 + includes/api/ApiQueryFileRepoInfo.php | 1 + includes/api/ApiQueryFilearchive.php | 4 ++-- includes/api/ApiQueryIWBacklinks.php | 6 +++--- includes/api/ApiQueryIWLinks.php | 14 +++++++------- includes/api/ApiQueryImageInfo.php | 17 +++++++++++++---- includes/api/ApiQueryImages.php | 6 +++--- includes/api/ApiQueryInfo.php | 18 ++++++++++-------- 10 files changed, 49 insertions(+), 34 deletions(-) diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 8273313346..0eb1ec74a1 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -172,10 +172,10 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); $op = ( $dir == 'newer' ? '>' : '<' ); $this->addWhere( "ar_namespace $op $ns OR " . - "(ar_namespace = $ns AND " . - "(ar_title $op $title OR " . - "(ar_title = $title AND " . - "ar_timestamp $op= $ts)))" ); + "(ar_namespace = $ns AND " . + "(ar_title $op $title OR " . + "(ar_title = $title AND " . + "ar_timestamp $op= $ts)))" ); } $this->addOption( 'LIMIT', $limit + 1 ); @@ -188,7 +188,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $this->addOption( 'ORDER BY', array( 'ar_title' . $sort, 'ar_timestamp' . $sort - )); + ) ); } } else { if ( $mode == 'revs' ) { @@ -385,6 +385,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { public function getDescription() { $p = $this->getModulePrefix(); + return array( 'List deleted revisions.', 'Operates in three modes:', diff --git a/includes/api/ApiQueryExtLinksUsage.php b/includes/api/ApiQueryExtLinksUsage.php index 456e87ba91..ae42bf73b2 100644 --- a/includes/api/ApiQueryExtLinksUsage.php +++ b/includes/api/ApiQueryExtLinksUsage.php @@ -101,7 +101,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { $result = $this->getResult(); $count = 0; 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( 'offset', $offset + $limit ); break; @@ -140,7 +140,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), - $this->getModulePrefix() ); + $this->getModulePrefix() ); } } @@ -186,6 +186,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { $protocols[] = substr( $p, 0, strpos( $p, ':' ) ); } } + return $protocols; } diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index 583ef697e6..fb132c0679 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -127,6 +127,7 @@ class ApiQueryExternalLinks extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'limit' => 'How many links to return', 'offset' => 'When more results are available, use this to continue', diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php index 3a353533b0..9a12ba1491 100644 --- a/includes/api/ApiQueryFileRepoInfo.php +++ b/includes/api/ApiQueryFileRepoInfo.php @@ -91,6 +91,7 @@ class ApiQueryFileRepoInfo extends ApiQueryBase { public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => array( 'Which repository properties to get (there may be more available on some wikis):', diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index f53cd38673..1b2da26cea 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -180,8 +180,8 @@ class ApiQueryFilearchive extends ApiQueryBase { } if ( $fld_metadata ) { $file['metadata'] = $row->fa_metadata - ? ApiQueryImageInfo::processMetaData( unserialize( $row->fa_metadata ), $result ) - : null; + ? ApiQueryImageInfo::processMetaData( unserialize( $row->fa_metadata ), $result ) + : null; } if ( $fld_bitdepth ) { $file['bitdepth'] = $row->fa_bits; diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index ebae3e768c..bb6a23a0ba 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -92,14 +92,14 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $this->addOption( 'ORDER BY', array( 'iwl_title' . $sort, 'iwl_from' . $sort - )); + ) ); } } else { $this->addOption( 'ORDER BY', array( 'iwl_prefix' . $sort, 'iwl_title' . $sort, 'iwl_from' . $sort - )); + ) ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); @@ -111,7 +111,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $count = 0; $result = $this->getResult(); 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... // Continue string preserved in case the redirect query doesn't pass the limit $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index be53931172..a3398686cf 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -81,9 +81,9 @@ class ApiQueryIWLinks extends ApiQueryBase { $this->addOption( 'ORDER BY', 'iwl_from' . $sort ); } else { $this->addOption( 'ORDER BY', array( - 'iwl_from' . $sort, - 'iwl_title' . $sort - )); + 'iwl_from' . $sort, + 'iwl_title' . $sort + ) ); } } else { // Don't order by iwl_from if it's constant in the WHERE clause @@ -91,10 +91,10 @@ class ApiQueryIWLinks extends ApiQueryBase { $this->addOption( 'ORDER BY', 'iwl_prefix' . $sort ); } else { $this->addOption( 'ORDER BY', array( - 'iwl_from' . $sort, - 'iwl_prefix' . $sort, - 'iwl_title' . $sort - )); + 'iwl_from' . $sort, + 'iwl_prefix' . $sort, + 'iwl_title' . $sort + ) ); } } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 81c9faf0c8..990130f874 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -267,6 +267,7 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( !$h ) { $this->setWarning( 'Could not create thumbnail because ' . $image->getName() . ' does not have an associated image handler' ); + return $thumbParams; } @@ -278,6 +279,7 @@ class ApiQueryImageInfo extends ApiQueryBase { // handlers. $this->setWarning( "Could not parse {$p}urlparam for " . $image->getName() . '. Using only width and height' ); + return $thumbParams; } @@ -389,7 +391,8 @@ class ApiQueryImageInfo extends ApiQueryBase { $uploadwarning = isset( $prop['uploadwarning'] ); if ( ( $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth ) - && $file->isDeleted( File::DELETED_FILE ) ) { + && $file->isDeleted( File::DELETED_FILE ) + ) { $vals['filehidden'] = ''; //Early return, tidier than indenting all following things one level @@ -505,6 +508,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } } $result->setIndexedTagName( $retval, 'metadata' ); + return $retval; } @@ -521,11 +525,13 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( $start === null ) { $start = $img->getTimestamp(); } + return $img->getOriginalTitle()->getDBkey() . '|' . $start; } public function getAllowedParams() { global $wgContLang; + return array( 'prop' => array( ApiBase::PARAM_ISMULTI => true, @@ -634,6 +640,7 @@ class ApiQueryImageInfo extends ApiQueryBase { */ public function getParamDescription() { $p = $this->getModulePrefix(); + return array( 'prop' => self::getPropertyDescriptions( array(), $p ), 'urlwidth' => array( "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.", @@ -646,10 +653,10 @@ class ApiQueryImageInfo extends ApiQueryBase { 'start' => 'Timestamp to start listing from', 'end' => 'Timestamp to stop listing at', 'metadataversion' => array( "Version of metadata to use. if 'latest' is specified, use latest version.", - "Defaults to '1' for backwards compatibility" ), + "Defaults to '1' for backwards compatibility" ), 'extmetadatalanguage' => array( 'What language to fetch extmetadata in. This affects both which', - 'translation to fetch, if multiple are available, as well as how things', - 'like numbers and various values are formatted.' ), + 'translation to fetch, if multiple are available, as well as how things', + 'like numbers and various values are formatted.' ), 'extmetadatamultilang' => 'If translations for extmetadata property are available, fetch all of them.', 'continue' => 'If the query response includes a continue value, use it here to get another page of results', 'localonly' => 'Look only for files in the local repository', @@ -773,6 +780,7 @@ class ApiQueryImageInfo extends ApiQueryBase { ) ), ); + return array_diff_key( $props, array_flip( $filter ) ); } @@ -786,6 +794,7 @@ class ApiQueryImageInfo extends ApiQueryBase { public function getPossibleErrors() { $p = $this->getModulePrefix(); + return array_merge( parent::getPossibleErrors(), array( array( 'code' => "{$p}urlwidth", 'info' => "{$p}urlheight cannot be used without {$p}urlwidth" ), array( 'code' => 'urlparam', 'info' => "Invalid value for {$p}urlparam" ), diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index f2bf0a7b48..7ec69b7257 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -79,9 +79,9 @@ class ApiQueryImages extends ApiQueryGeneratorBase { $this->addOption( 'ORDER BY', 'il_to' . $sort ); } else { $this->addOption( 'ORDER BY', array( - 'il_from' . $sort, - 'il_to' . $sort - )); + 'il_from' . $sort, + 'il_to' . $sort + ) ); } $this->addOption( 'LIMIT', $params['limit'] + 1 ); diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 017684edd3..7890a40715 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -104,6 +104,7 @@ class ApiQueryInfo extends ApiQueryBase { 'watch' => array( 'ApiQueryInfo', 'getWatchToken' ), ); wfRunHooks( 'APIQueryInfoTokens', array( &$this->tokenFunctions ) ); + return $this->tokenFunctions; } @@ -333,8 +334,8 @@ class ApiQueryInfo extends ApiQueryBase { ), $pageid, $pageInfo ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', - $title->getNamespace() . '|' . - $title->getText() ); + $title->getNamespace() . '|' . + $title->getText() ); break; } } @@ -465,7 +466,7 @@ class ApiQueryInfo extends ApiQueryBase { $this->resetQueryParams(); $this->addTables( 'page_restrictions' ); $this->addFields( array( 'pr_page', 'pr_type', 'pr_level', - 'pr_expiry', 'pr_cascade' ) ); + 'pr_expiry', 'pr_cascade' ) ); $this->addWhereFld( 'pr_page', array_keys( $this->titles ) ); $res = $this->select( __METHOD__ ); @@ -556,8 +557,8 @@ class ApiQueryInfo extends ApiQueryBase { $this->resetQueryParams(); $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) ); $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry', - 'page_title', 'page_namespace', - 'tl_title', 'tl_namespace' ) ); + 'page_title', 'page_namespace', + 'tl_title', 'tl_namespace' ) ); $this->addWhere( $lb->constructSet( 'tl', $db ) ); $this->addWhere( 'pr_page = page_id' ); $this->addWhere( 'pr_page = tl_from' ); @@ -580,7 +581,7 @@ class ApiQueryInfo extends ApiQueryBase { $this->resetQueryParams(); $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) ); $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry', - 'page_title', 'page_namespace', 'il_to' ) ); + 'page_title', 'page_namespace', 'il_to' ) ); $this->addWhere( 'pr_page = page_id' ); $this->addWhere( 'pr_page = il_from' ); $this->addWhereFld( 'pr_cascade', 1 ); @@ -633,10 +634,10 @@ class ApiQueryInfo extends ApiQueryBase { foreach ( $res as $row ) { if ( MWNamespace::isTalk( $row->page_namespace ) ) { $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] = - intval( $row->page_id ); + intval( $row->page_id ); } else { $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] = - intval( $row->page_id ); + intval( $row->page_id ); } } } @@ -761,6 +762,7 @@ class ApiQueryInfo extends ApiQueryBase { if ( !is_null( $params['token'] ) ) { return 'private'; } + return 'public'; } -- 2.20.1