jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356215 )

Change subject: Add phpcs and make pass
......................................................................


Add phpcs and make pass

Change-Id: I45262b760dd004a3a3eb629f6293cf078a046a3e
---
M GlobalUsage.php
M composer.json
M includes/ApiQueryGlobalUsage.php
M includes/GlobalUsageHooks.php
M includes/GlobalUsageImagePageHooks.php
M includes/SpecialGlobalUsage.php
M includes/SpecialGloballyWantedFiles.php
M includes/SpecialMostGloballyLinkedFiles.php
A phpcs.xml
M refreshGlobalimagelinks.php
10 files changed, 50 insertions(+), 31 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/GlobalUsage.php b/GlobalUsage.php
index 3db8fed..7947c43 100644
--- a/GlobalUsage.php
+++ b/GlobalUsage.php
@@ -30,7 +30,8 @@
        $wgMessagesDirs['GlobalUsage'] = __DIR__ . '/i18n';
        $wgExtensionMessagesFiles['GlobalUsageAliases'] = __DIR__ . 
'/GlobalUsage.alias.php';
        /* wfWarn(
-               'Deprecated PHP entry point used for GlobalUsage extension. 
Please use wfLoadExtension instead, ' .
+               'Deprecated PHP entry point used for GlobalUsage extension. ' .
+               'Please use wfLoadExtension instead, ' .
                'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
        ); */
        return;
diff --git a/composer.json b/composer.json
index 686b65b..b8f68fb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,11 +1,14 @@
 {
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9.2",
-               "jakub-onderka/php-console-highlighter": "0.3.2"
+               "jakub-onderka/php-console-highlighter": "0.3.2",
+               "mediawiki/mediawiki-codesniffer": "0.7.2"
        },
        "scripts": {
+               "fix": "phpcbf",
                "test": [
-                       "parallel-lint . --exclude vendor"
+                       "parallel-lint . --exclude vendor",
+                       "phpcs -p -s"
                ]
        }
 }
diff --git a/includes/ApiQueryGlobalUsage.php b/includes/ApiQueryGlobalUsage.php
index 71b46f1..0c1ddc8 100644
--- a/includes/ApiQueryGlobalUsage.php
+++ b/includes/ApiQueryGlobalUsage.php
@@ -61,8 +61,10 @@
                                                        'wiki' => 
WikiMap::getWikiName( $wiki )
                                                ];
                                                if ( isset( $prop['url'] ) ) {
-                                                       /* We expand the url 
because we don't want protocol relative urls in API results */
-                                                       $result['url'] = 
wfExpandUrl( WikiMap::getForeignUrl( $item['wiki'], $title ), PROTO_CURRENT );
+                                                       // We expand the url 
because we don't want protocol relative urls
+                                                       // in API results
+                                                       $result['url'] = 
wfExpandUrl(
+                                                               
WikiMap::getForeignUrl( $item['wiki'], $title ), PROTO_CURRENT );
                                                }
                                                if ( isset( $prop['pageid'] ) ) 
{
                                                        $result['pageid'] = 
$item['id'];
diff --git a/includes/GlobalUsageHooks.php b/includes/GlobalUsageHooks.php
index 3228395..8c6729a 100644
--- a/includes/GlobalUsageHooks.php
+++ b/includes/GlobalUsageHooks.php
@@ -208,12 +208,14 @@
                        $updater->addExtensionUpdate( [ 'addTable', 
'globalimagelinks',
                                "$dir/GlobalUsage.sql", true ] );
                        $updater->addExtensionUpdate( [ 'addIndex', 
'globalimagelinks',
-                               'globalimagelinks_wiki_nsid_title', 
"$dir/patch-globalimagelinks_wiki_nsid_title.sql", true ] );
+                               'globalimagelinks_wiki_nsid_title',
+                               
"$dir/patch-globalimagelinks_wiki_nsid_title.sql", true ] );
                } elseif ( $updater->getDB()->getType() == 'postgresql' ) {
                        $updater->addExtensionUpdate( [ 'addTable', 
'globalimagelinks',
                                "$dir/GlobalUsage.pg.sql", true ] );
                        $updater->addExtensionUpdate( [ 'addIndex', 
'globalimagelinks',
-                               'globalimagelinks_wiki_nsid_title', 
"$dir/patch-globalimagelinks_wiki_nsid_title.pg.sql", true ] );
+                               'globalimagelinks_wiki_nsid_title',
+                               
"$dir/patch-globalimagelinks_wiki_nsid_title.pg.sql", true ] );
                }
                return true;
        }
diff --git a/includes/GlobalUsageImagePageHooks.php 
b/includes/GlobalUsageImagePageHooks.php
index 07f4de8..9ba97f6 100644
--- a/includes/GlobalUsageImagePageHooks.php
+++ b/includes/GlobalUsageImagePageHooks.php
@@ -52,8 +52,9 @@
                        $guHtml .= "<li class='mw-gu-onwiki-$escWikiName'>" . 
$context->msg(
                                'globalusage-on-wiki',
                                $targetName, $wikiName )->parse() . "\n<ul>";
-                       foreach ( $result as $item )
+                       foreach ( $result as $item ) {
                                $guHtml .= "\t<li>" . 
SpecialGlobalUsage::formatItem( $item ) . "</li>\n";
+                       }
                        $guHtml .= "</ul></li>\n";
                }
 
@@ -101,7 +102,7 @@
                }
 
                # Don't show global usage if the file is local.
-               # Do show it however if the current repo is the shared repo. 
The way 
+               # Do show it however if the current repo is the shared repo. 
The way
                # we detect this is a bit hacky and less than ideal. See bug 
23136 for
                # a discussion.
                global $wgGlobalUsageDatabase;
diff --git a/includes/SpecialGlobalUsage.php b/includes/SpecialGlobalUsage.php
index 6f17ced..1942cde 100644
--- a/includes/SpecialGlobalUsage.php
+++ b/includes/SpecialGlobalUsage.php
@@ -41,7 +41,8 @@
                        return;
                }
 
-               $this->getOutput()->setPageTitle( $this->msg( 
'globalusage-for', $this->target->getPrefixedText() ) );
+               $this->getOutput()->setPageTitle(
+                       $this->msg( 'globalusage-for', 
$this->target->getPrefixedText() ) );
 
                $this->showResult();
        }
diff --git a/includes/SpecialGloballyWantedFiles.php 
b/includes/SpecialGloballyWantedFiles.php
index b5239ec..e389c3d 100644
--- a/includes/SpecialGloballyWantedFiles.php
+++ b/includes/SpecialGloballyWantedFiles.php
@@ -18,7 +18,6 @@
         * If we're not on a shared repo, try to redirect there.
         */
        function execute( $par ) {
-               global $wgGlobalUsageSharedRepoWiki;
                if ( GlobalUsage::onSharedRepo() ) {
                        parent::execute( $par );
                } else {
diff --git a/includes/SpecialMostGloballyLinkedFiles.php 
b/includes/SpecialMostGloballyLinkedFiles.php
index 3d1218b..fea86e9 100644
--- a/includes/SpecialMostGloballyLinkedFiles.php
+++ b/includes/SpecialMostGloballyLinkedFiles.php
@@ -18,7 +18,6 @@
         * If we're not on a shared repo, try to redirect there.
         */
        function execute( $par ) {
-               global $wgGlobalUsageSharedRepoWiki;
                if ( GlobalUsage::onSharedRepo() ) {
                        parent::execute( $par );
                } else {
@@ -62,7 +61,9 @@
         */
        protected function assertOnSharedRepo() {
                if ( !GlobalUsage::onSharedRepo() ) {
-                       throw new Exception( "Special:MostGloballyLinkedFiles 
should only be processed on the shared repo" );
+                       throw new Exception(
+                               'Special:MostGloballyLinkedFiles should only be 
processed on the shared repo'
+                       );
                }
        }
 
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..4ffde0b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+       <file>.</file>
+       <arg name="extensions" value="php,php5,inc"/>
+       <arg name="encoding" value="UTF-8"/>
+       <exclude-pattern>vendor</exclude-pattern>
+       <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>
diff --git a/refreshGlobalimagelinks.php b/refreshGlobalimagelinks.php
index 379c2bf..9fa4c53 100644
--- a/refreshGlobalimagelinks.php
+++ b/refreshGlobalimagelinks.php
@@ -3,13 +3,13 @@
  * Maintenance script to populate the globalimagelinks table. Needs to be run
  * on all wikis.
  */
-$path = dirname( dirname( dirname( __FILE__ ) ) );
+$path = dirname( dirname( __DIR__ ) );
 
 if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
        $path = getenv( 'MW_INSTALL_PATH' );
 }
 
-require_once( $path . '/maintenance/Maintenance.php' );
+require_once $path . '/maintenance/Maintenance.php';
 
 use MediaWiki\MediaWikiServices;
 
@@ -43,33 +43,33 @@
                                # Query all pages and any imagelinks associated 
with that
                                $quotedLastIlTo = $dbr->addQuotes( $lastIlTo );
                                $res = $dbr->select(
-                                       array( 'page', 'imagelinks', 'image' ),
-                                       array(
+                                       [ 'page', 'imagelinks', 'image' ],
+                                       [
                                                'page_id', 'page_namespace', 
'page_title',
                                                'il_to', 'img_name'
-                                       ),
+                                       ],
                                        "(page_id = $lastPageId AND il_to > 
{$quotedLastIlTo})" .
                                                " OR page_id > $lastPageId",
                                        __METHOD__,
-                                       array(
+                                       [
                                                'ORDER BY' => 
$dbr->implicitOrderby() ? 'page_id' : 'page_id, il_to',
                                                'LIMIT' => $this->mBatchSize,
-                                       ),
-                                       array(
+                                       ],
+                                       [
                                                # LEFT JOIN imagelinks since we 
need to delete usage
                                                # from all images, even if they 
don't have images anymore
-                                               'imagelinks' => array( 'LEFT 
JOIN', 'page_id = il_from' ),
+                                               'imagelinks' => [ 'LEFT JOIN', 
'page_id = il_from' ],
                                                # Check to see if images exist 
locally
-                                               'image' => array( 'LEFT JOIN', 
'il_to = img_name' )
-                                       )
+                                               'image' => [ 'LEFT JOIN', 
'il_to = img_name' ]
+                                       ]
                                );
 
                                # Build up a tree per pages
-                               $pages = array();
+                               $pages = [];
                                $lastRow = null;
                                foreach ( $res as $row ) {
                                        if ( !isset( $pages[$row->page_id] ) ) {
-                                               $pages[$row->page_id] = array();
+                                               $pages[$row->page_id] = [];
                                        }
                                        # Add the imagelinks entry to the pages 
array if the image
                                        # does not exist locally
@@ -114,23 +114,23 @@
                                $this->output( "Querying for broken links after 
(page_id) = ($lastPageId)\n" );
 
                                $res = $gdbw->select( 'globalimagelinks', 
'gil_page',
-                                       array( 'gil_wiki' => wfWikiID(), 
"gil_page > $lastPageId" ),
+                                       [ 'gil_wiki' => wfWikiID(), "gil_page > 
$lastPageId" ],
                                        __METHOD__,
-                                       array( 'ORDER BY' => 'gil_page', 
'LIMIT' => $this->mBatchSize )
+                                       [ 'ORDER BY' => 'gil_page', 'LIMIT' => 
$this->mBatchSize ]
                                );
 
                                if ( !$res->numRows() ) {
                                        break;
                                }
 
-                               $pageIds = array();
+                               $pageIds = [];
                                foreach ( $res as $row ) {
                                        $pageIds[$row->gil_page] = false;
                                        $lastPageId = (int)$row->gil_page;
                                }
 
                                $lres = $dbr->select( 'page', 'page_id',
-                                       array( 'page_id' => array_keys( 
$pageIds ) ), __METHOD__ );
+                                       [ 'page_id' => array_keys( $pageIds ) 
], __METHOD__ );
 
                                foreach ( $lres as $row ) {
                                        $pageIds[$row->page_id] = true;
@@ -153,4 +153,4 @@
 }
 
 $maintClass = 'RefreshGlobalImageLinks';
-require_once( DO_MAINTENANCE );
+require_once DO_MAINTENANCE;

-- 
To view, visit https://gerrit.wikimedia.org/r/356215
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I45262b760dd004a3a3eb629f6293cf078a046a3e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GlobalUsage
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to