From a2dc799364499a3d0bbaf2d7b9609bef6e41bcf7 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 14 Nov 2013 17:17:22 +0100 Subject: [PATCH] Fix a few more CodeSniffer errors and warnings on some API classes Change-Id: I119be629d8c8811d08413751bcffc0ce403cc2bd --- includes/api/ApiQueryDuplicateFiles.php | 3 +- includes/api/ApiQueryExtLinksUsage.php | 6 ++- includes/api/ApiQueryExternalLinks.php | 6 ++- includes/api/ApiQueryFileRepoInfo.php | 8 +++- includes/api/ApiQueryFilearchive.php | 26 +++++++++---- includes/api/ApiQueryIWBacklinks.php | 16 ++++++-- includes/api/ApiQueryIWLinks.php | 13 +++++-- includes/api/ApiQueryImageInfo.php | 49 ++++++++++++++++--------- 8 files changed, 89 insertions(+), 38 deletions(-) diff --git a/includes/api/ApiQueryDuplicateFiles.php b/includes/api/ApiQueryDuplicateFiles.php index 0311fa7fec..185469499b 100644 --- a/includes/api/ApiQueryDuplicateFiles.php +++ b/includes/api/ApiQueryDuplicateFiles.php @@ -95,7 +95,8 @@ class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase { $sha1s[$file->getName()] = $file->getSha1(); } - // find all files with the hashes, result format is: array( hash => array( dup1, dup2 ), hash1 => ... ) + // find all files with the hashes, result format is: + // array( hash => array( dup1, dup2 ), hash1 => ... ) $filesToFindBySha1s = array_unique( array_values( $sha1s ) ); if ( $params['localonly'] ) { $filesBySha1s = RepoGroup::singleton()->getLocalRepo()->findBySha1s( $filesToFindBySha1s ); diff --git a/includes/api/ApiQueryExtLinksUsage.php b/includes/api/ApiQueryExtLinksUsage.php index ae42bf73b2..d22081773a 100644 --- a/includes/api/ApiQueryExtLinksUsage.php +++ b/includes/api/ApiQueryExtLinksUsage.php @@ -102,7 +102,8 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { $count = 0; 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( 'offset', $offset + $limit ); break; } @@ -222,7 +223,8 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { "Protocol of the URL. If empty and {$p}query set, the protocol is http.", "Leave both this and {$p}query empty to list all external links" ), - 'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links', + 'query' => 'Search string without protocol. See [[Special:LinkSearch]]. ' . + 'Leave empty to list all external links', 'namespace' => 'The page namespace(s) to enumerate.', 'limit' => 'How many pages to return.', 'expandurl' => 'Expand protocol-relative URLs with the canonical protocol', diff --git a/includes/api/ApiQueryExternalLinks.php b/includes/api/ApiQueryExternalLinks.php index fb132c0679..5803ea7b44 100644 --- a/includes/api/ApiQueryExternalLinks.php +++ b/includes/api/ApiQueryExternalLinks.php @@ -135,7 +135,8 @@ class ApiQueryExternalLinks extends ApiQueryBase { "Protocol of the URL. If empty and {$p}query set, the protocol is http.", "Leave both this and {$p}query empty to list all external links" ), - 'query' => 'Search string without protocol. Useful for checking whether a certain page contains a certain external url', + 'query' => 'Search string without protocol. Useful for checking ' . + 'whether a certain page contains a certain external url', 'expandurl' => 'Expand protocol-relative URLs with the canonical protocol', ); } @@ -160,7 +161,8 @@ class ApiQueryExternalLinks extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]', + 'api.php?action=query&prop=extlinks&titles=Main%20Page' + => 'Get a list of external links on the [[Main Page]]', ); } diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php index 9a12ba1491..3d4d38f722 100644 --- a/includes/api/ApiQueryFileRepoInfo.php +++ b/includes/api/ApiQueryFileRepoInfo.php @@ -86,7 +86,10 @@ class ApiQueryFileRepoInfo extends ApiQueryBase { $props = array_merge( $props, array_keys( $repo->getInfo() ) ); } ); - return array_values( array_unique( array_merge( $props, array_keys( $repoGroup->localRepo->getInfo() ) ) ) ); + return array_values( array_unique( array_merge( + $props, + array_keys( $repoGroup->localRepo->getInfo() ) + ) ) ); } public function getParamDescription() { @@ -96,7 +99,8 @@ class ApiQueryFileRepoInfo extends ApiQueryBase { 'prop' => array( 'Which repository properties to get (there may be more available on some wikis):', ' apiurl - URL to the repository API - helpful for getting image info from the host.', - ' name - The key of the repository - used in e.g. $wgForeignFileRepos and imageinfo return values.', + ' name - The key of the repository - used in e.g. ' . + '$wgForeignFileRepos and imageinfo return values.', ' displayname - The human-readable name of the repository wiki.', ' rooturl - Root URL for image paths.', ' local - Whether that repository is the local one or not.', diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 1b2da26cea..f8f455800e 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -41,7 +41,10 @@ class ApiQueryFilearchive extends ApiQueryBase { $user = $this->getUser(); // Before doing anything at all, let's check permissions if ( !$user->isAllowed( 'deletedhistory' ) ) { - $this->dieUsage( 'You don\'t have permission to view deleted file information', 'permissiondenied' ); + $this->dieUsage( + 'You don\'t have permission to view deleted file information', + 'permissiondenied' + ); } $db = $this->getDB(); @@ -92,7 +95,8 @@ class ApiQueryFilearchive extends ApiQueryBase { $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); $this->addWhereRange( 'fa_name', $dir, $from, $to ); if ( isset( $params['prefix'] ) ) { - $this->addWhere( 'fa_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( 'fa_name' . + $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } $sha1Set = isset( $params['sha1'] ); @@ -137,7 +141,8 @@ class ApiQueryFilearchive extends ApiQueryBase { $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->fa_name ); break; } @@ -275,7 +280,8 @@ class ApiQueryFilearchive extends ApiQueryBase { ' sha1 - Adds SHA-1 hash for the image', ' timestamp - Adds timestamp for the uploaded version', ' user - Adds user who uploaded the image version', - ' size - Adds the size of the image in bytes and the height, width and page count (if applicable)', + ' size - Adds the size of the image in bytes and the height, ' . + 'width and page count (if applicable)', ' dimensions - Alias for size', ' description - Adds description the image version', ' parseddescription - Parse the description on the version', @@ -358,10 +364,16 @@ class ApiQueryFilearchive extends ApiQueryBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted file information' ), + array( + 'code' => 'permissiondenied', + 'info' => 'You don\'t have permission to view deleted file information' + ), array( 'code' => 'hashsearchdisabled', 'info' => 'Search by hash 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' => 'invalidsha1hash', 'info' => 'The SHA-1 hash provided is not valid' ), + array( + 'code' => 'invalidsha1base36hash', + 'info' => 'The SHA1Base36 hash provided is not valid' + ), ) ); } diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index bb6a23a0ba..03a72a6067 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -112,9 +112,14 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $result = $this->getResult(); foreach ( $res as $row ) { 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}" ); + // 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}" + ); break; } @@ -140,7 +145,10 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); if ( !$fit ) { - $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); + $this->setContinueEnumParameter( + 'continue', + "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" + ); break; } } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index a3398686cf..be64d36921 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -106,7 +106,10 @@ class ApiQueryIWLinks extends ApiQueryBase { if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that // there are additional pages to be had. Stop here... - $this->setContinueEnumParameter( 'continue', "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" ); + $this->setContinueEnumParameter( + 'continue', + "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" + ); break; } $entry = array( 'prefix' => $row->iwl_prefix ); @@ -121,7 +124,10 @@ class ApiQueryIWLinks extends ApiQueryBase { ApiResult::setContent( $entry, $row->iwl_title ); $fit = $this->addPageSubItem( $row->iwl_from, $entry ); if ( !$fit ) { - $this->setContinueEnumParameter( 'continue', "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" ); + $this->setContinueEnumParameter( + 'continue', + "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" + ); break; } } @@ -190,7 +196,8 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getExamples() { return array( - 'api.php?action=query&prop=iwlinks&titles=Main%20Page' => 'Get interwiki links from the [[Main Page]]', + 'api.php?action=query&prop=iwlinks&titles=Main%20Page' + => 'Get interwiki links from the [[Main Page]]', ); } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 96840e860b..9981ec1213 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -34,8 +34,9 @@ class ApiQueryImageInfo extends ApiQueryBase { private static $transformCount = 0; public function __construct( $query, $moduleName, $prefix = 'ii' ) { - // We allow a subclass to override the prefix, to create a related API module. - // Some other parts of MediaWiki construct this with a null $prefix, which used to be ignored when this only took two arguments + // We allow a subclass to override the prefix, to create a related API + // module. Some other parts of MediaWiki construct this with a null + // $prefix, which used to be ignored when this only took two arguments if ( is_null( $prefix ) ) { $prefix = 'ii'; } @@ -176,7 +177,8 @@ class ApiQueryImageInfo extends ApiQueryBase { /** @var $oldie File */ foreach ( $oldies as $oldie ) { if ( ++$count > $params['limit'] ) { - // We've reached the extra one which shows that there are additional pages to be had. Stop here... + // We've reached the extra one which shows that there are + // additional pages to be had. Stop here... // Only set a query-continue if there was only one title if ( count( $pageIds[NS_FILE] ) == 1 ) { $this->setContinueEnumParameter( 'start', @@ -287,7 +289,8 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( isset( $paramList['width'] ) ) { if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) { $this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) " - . "in favor of width value derived from {$p}urlwidth/{$p}urlheight ({$thumbParams['width']})" ); + . "in favor of width value derived from {$p}urlwidth/{$p}urlheight " + . "({$thumbParams['width']})" ); } } @@ -616,18 +619,22 @@ class ApiQueryImageInfo extends ApiQueryBase { 'comment' => ' comment - Comment on the version', 'parsedcomment' => ' parsedcomment - Parse the comment on the version', 'url' => ' url - Gives URL to the image and the description page', - 'size' => ' size - Adds the size of the image in bytes and the height, width and page count (if applicable)', - 'dimensions' => ' dimensions - Alias for size', // For backwards compatibility with Allimages + 'size' => ' size - Adds the size of the image in bytes ' . + 'and the height, width and page count (if applicable)', + 'dimensions' => ' dimensions - Alias for size', // B/C with Allimages 'sha1' => ' sha1 - Adds SHA-1 hash for the image', 'mime' => ' mime - Adds MIME type of the image', 'thumbmime' => ' thumbmime - Adds MIME type of the image thumbnail' . ' (requires url and param ' . $modulePrefix . 'urlwidth)', 'mediatype' => ' mediatype - Adds the media type of the image', 'metadata' => ' metadata - Lists Exif metadata for the version of the image', - 'extmetadata' => ' extmetadata - Lists formatted metadata combined from multiple sources. Results are HTML formatted.', - 'archivename' => ' archivename - Adds the file name of the archive version for non-latest versions', + 'extmetadata' => ' extmetadata - Lists formatted metadata combined ' . + 'from multiple sources. Results are HTML formatted.', + 'archivename' => ' archivename - Adds the file name of the archive ' . + 'version for non-latest versions', 'bitdepth' => ' bitdepth - Adds the bit depth of the version', - 'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to get information about an existing file. Not intended for use outside MediaWiki core', + 'uploadwarning' => ' uploadwarning - Used by the Special:Upload page to ' . + 'get information about an existing file. Not intended for use outside MediaWiki core', ); } @@ -654,22 +661,29 @@ class ApiQueryImageInfo extends ApiQueryBase { 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.", + 'urlwidth' => array( + "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.", 'For performance reasons if this option is used, ' . - 'no more than ' . self::TRANSFORM_LIMIT . ' scaled images will be returned.' ), + 'no more than ' . self::TRANSFORM_LIMIT . ' scaled images will be returned.' + ), 'urlheight' => "Similar to {$p}urlwidth.", 'urlparam' => array( "A handler specific parameter string. For example, pdf's ", "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ), 'limit' => 'How many image revisions to return per image', '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.", + 'metadataversion' + => array( "Version of metadata to use. if 'latest' is specified, use latest version.", "Defaults to '1' for backwards compatibility" ), - 'extmetadatalanguage' => array( 'What language to fetch extmetadata in. This affects both which', + '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.' ), - 'extmetadatamultilang' => 'If translations for extmetadata property are available, fetch all of them.', - 'extmetadatafilter' => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata", + 'like numbers and various values are formatted.' + ), + 'extmetadatamultilang' + =>'If translations for extmetadata property are available, fetch all of them.', + 'extmetadatafilter' + => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata", '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', ); @@ -817,7 +831,8 @@ class ApiQueryImageInfo extends ApiQueryBase { public function getExamples() { return array( 'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo', - 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=20071231235959&iiprop=timestamp|user|url', + 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' . + 'iiend=20071231235959&iiprop=timestamp|user|url', ); } -- 2.20.1