Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364106 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: I48b8b4389d7a9dbb2ae33d7c86defed56adda93c
---
M GlobalCssJs.hooks.php
M GlobalCssJs.php
M ResourceLoaderGlobalModule.php
M ResourceLoaderGlobalSiteModule.php
M phpcs.xml
M removeOldManualUserPages.php
M tests/phpunit/RemoveOldManualUserPagesTest.php
7 files changed, 102 insertions(+), 42 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs
refs/changes/06/364106/1
diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php
index a270822..8491a77 100644
--- a/GlobalCssJs.hooks.php
+++ b/GlobalCssJs.hooks.php
@@ -123,9 +123,13 @@
) {
$title = $editPage->getTitle();
$name = $user->getName();
- if ( $config->get( 'AllowUserJs' ) &&
$editPage->isJsSubpage && $title->getText() == $name . '/global.js' ) {
+ if ( $config->get( 'AllowUserJs' ) &&
$editPage->isJsSubpage &&
+ $title->getText() == $name . '/global.js'
+ ) {
$msg = 'globalcssjs-warning-js';
- } elseif ( $config->get( 'AllowUserCss' ) &&
$editPage->isCssSubpage && $title->getText() == $name . '/global.css' ) {
+ } elseif ( $config->get( 'AllowUserCss' ) &&
$editPage->isCssSubpage &&
+ $title->getText() == $name . '/global.css'
+ ) {
$msg = 'globalcssjs-warning-css';
} else {
// CSS or JS page, but not a global one
diff --git a/GlobalCssJs.php b/GlobalCssJs.php
index aca4c7c..616c809 100644
--- a/GlobalCssJs.php
+++ b/GlobalCssJs.php
@@ -5,7 +5,8 @@
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['GlobalCssJs'] = __DIR__ . '/i18n/core';
/* wfWarn(
- 'Deprecated PHP entry point used for GlobalCssJs extension.
Please use wfLoadExtension instead, ' .
+ 'Deprecated PHP entry point used for GlobalCssJs extension. ' .
+ 'Please use wfLoadExtension instead, ' .
'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
); */
return true;
diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php
index 36dc33e..ad37fe2 100644
--- a/ResourceLoaderGlobalModule.php
+++ b/ResourceLoaderGlobalModule.php
@@ -56,7 +56,9 @@
break;
case 'type':
if ( $option !== 'style' && $option !==
'script' ) {
- throw new
InvalidArgumentException( "type must be either 'style' or 'script', not
'$option'" );
+ throw new
InvalidArgumentException(
+ "type must be either
'style' or 'script', not '$option'"
+ );
}
$this->type = $option;
break;
diff --git a/ResourceLoaderGlobalSiteModule.php
b/ResourceLoaderGlobalSiteModule.php
index ccc5e97..da58639 100644
--- a/ResourceLoaderGlobalSiteModule.php
+++ b/ResourceLoaderGlobalSiteModule.php
@@ -33,7 +33,9 @@
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
- if ( !ConfigFactory::getDefaultInstance()->makeConfig(
'globalcssjs' )->get( 'UseGlobalSiteCssJs' ) ) {
+ if ( !ConfigFactory::getDefaultInstance()
+ ->makeConfig( 'globalcssjs' )->get(
'UseGlobalSiteCssJs' )
+ ) {
return [];
}
diff --git a/phpcs.xml b/phpcs.xml
index 7097afc..5a35dc8 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
- <exclude name="Generic.Files.LineLength.TooLong" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
<exclude
name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
diff --git a/removeOldManualUserPages.php b/removeOldManualUserPages.php
index 1170b68..17b08da 100644
--- a/removeOldManualUserPages.php
+++ b/removeOldManualUserPages.php
@@ -20,9 +20,11 @@
public function __construct() {
parent::__construct();
- $this->mDescription = 'Remove reundant user script pages that
import global.js and/or global.css';
+ $this->mDescription = 'Remove reundant user script pages that '
.
+ 'import global.js and/or global.css';
$this->addOption( 'user', 'User name', true, true );
- $this->addOption( 'ignorerevisionlimit', 'Whether to ignore the
1 revision limit', false, false );
+ $this->addOption( 'ignorerevisionlimit',
+ 'Whether to ignore the 1 revision limit', false, false
);
}
public function execute() {
@@ -68,7 +70,9 @@
}
$rev = Revision::newFromTitle( $title );
- if ( !$this->ignoreRevisionLimit &&
$title->getPreviousRevisionID( $rev->getId() ) !== false ) {
+ if ( !$this->ignoreRevisionLimit &&
+ $title->getPreviousRevisionID( $rev->getId() ) !== false
+ ) {
$this->output( "{$title->getPrefixedText()} has more
than one revision, skipping.\n" );
return false;
}
@@ -101,11 +105,15 @@
// For hooks not using RequestContext (e.g. AbuseFilter)
$wgUser = $user;
$errors = [];
- $status = $page->doDeleteArticleReal( wfMessage( $reason,
$userName )->inContentLanguage()->text(), false, 0, true, $errors, $user );
+ $status = $page->doDeleteArticleReal(
+ wfMessage( $reason, $userName
)->inContentLanguage()->text(),
+ false, 0, true, $errors, $user
+ );
if ( $status->isGood() ) {
$this->output( "{$title->getPrefixedText()} was
deleted.\n" );
} else {
- $this->output( "{$title->getPrefixedText()} could not
be deleted:\n" . $status->getWikiText() . "\n" );
+ $this->output( "{$title->getPrefixedText()} could not
be deleted:\n" .
+ $status->getWikiText() . "\n" );
}
}
@@ -125,7 +133,8 @@
public function checkCss( $text, $domain, $userName ) {
$userName = $this->normalizeUserName( $userName );
- preg_match( "/@import
url\('(https?:)?\/\/$domain\/w\/index\.php\?title=User:$userName\/global\.css&action=raw&ctype=text\/css'\);/",
$text, $matches );
+ preg_match( "/@import
url\('(https?:)?\/\/$domain\/w\/index\.php\?title=User:$userName" .
+ "\/global\.css&action=raw&ctype=text\/css'\);/", $text,
$matches );
return isset( $matches[0] ) ? $matches[0] === $text : false;
}
@@ -142,7 +151,8 @@
$text = trim( $content->getNativeData() );
$domain = $this->getCentralWikiDomain();
if ( !$this->checkCss( $text, $domain, $userName ) ) {
- $this->output( "{$title->getPrefixedText()} did not
match the specified regular expression. Skipping.\n" );
+ $this->output( "{$title->getPrefixedText()} did not
match the specified regular " .
+ "expression. Skipping.\n" );
return;
}
@@ -173,7 +183,9 @@
public function checkJs( $text, $domain, $userName ) {
$text = $this->stripComments( $text );
$userName = $this->normalizeUserName( $userName );
- preg_match(
"/(mw\.loader\.load|importScriptURI)\s*\(\s*('|\")(https?:)?\/\/$domain\/w\/index\.php\?title=User:$userName\/global\.js&action=raw&ctype=text\/javascript(&smaxage=\d*?)?(&maxage=\d*?)?('|\")\s*\)\s*;?/",
$text, $matches );
+ preg_match(
"/(mw\.loader\.load|importScriptURI)\s*\(\s*('|\")(https?:)?\/\/$domain" .
+
"\/w\/index\.php\?title=User:$userName\/global\.js&action=raw&ctype=text\/javascript"
.
+ "(&smaxage=\d*?)?(&maxage=\d*?)?('|\")\s*\)\s*;?/",
$text, $matches );
return isset( $matches[0] ) ? $matches[0] === $text : false;
}
@@ -190,7 +202,8 @@
$text = trim( $content->getNativeData() );
$domain = $this->getCentralWikiDomain();
if ( !$this->checkJs( $text, $domain, $userName ) ) {
- $this->output( "{$title->getPrefixedText()} did not
match the specified regular expression. Skipping.\n" );
+ $this->output( "{$title->getPrefixedText()} did not
match the specified regular " .
+ "expression. Skipping.\n" );
return;
}
diff --git a/tests/phpunit/RemoveOldManualUserPagesTest.php
b/tests/phpunit/RemoveOldManualUserPagesTest.php
index ae4a18b..807d317 100644
--- a/tests/phpunit/RemoveOldManualUserPagesTest.php
+++ b/tests/phpunit/RemoveOldManualUserPagesTest.php
@@ -5,109 +5,127 @@
public static function provideCheckJs() {
return [
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+ "&action=raw&ctype=text/javascript');",
true,
'UserName',
'mw.loader.load with a proto-rel link',
],
[
-
'mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript");',
+
'mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+ "&action=raw&ctype=text/javascript");',
true,
'UserName',
'double quotes',
],
[
-
"importScriptURI('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+
"importScriptURI('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+ "&action=raw&ctype=text/javascript');",
true,
'UserName',
'using importScriptURI',
],
[
-
"mw.loader.load('http://meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('http://meta.wikimedia.org/w/index.php?title=User:UserName/" .
+
"global.js&action=raw&ctype=text/javascript');",
true,
'UserName',
'mw.loader.load with a http:// link',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:SomeOtherUserName/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:SomeOtherUserName/"
.
+
"global.js&action=raw&ctype=text/javascript');",
false,
'UserName',
'Loading a different user\'s global.js',
],
[
-
"mw.loader.load('//en.wikipedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//en.wikipedia.org/w/index.php?title=User:UserName/global.js" .
+ "&action=raw&ctype=text/javascript');",
false,
'UserName',
'Loading from a different site',
],
[
-
"mw.loader.load('//en.wikipedia.org/w/index.php?title=User:UserName/common.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//en.wikipedia.org/w/index.php?title=User:UserName/common.js" .
+ "&action=raw&ctype=text/javascript');",
false,
'UserName',
'Loading from a different page',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript')",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+ "&action=raw&ctype=text/javascript')",
true,
'UserName',
'No trailing ;',
],
[
- "mw.loader.load (
'//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript'
) ;",
+ "mw.loader.load (
'//meta.wikimedia.org/w/index.php?title=User:UserName/global.js" .
+ "&action=raw&ctype=text/javascript' )
;",
true,
'UserName',
'Spaces around ( and )',
],
[
- "//some comment\n//another
comment\nmw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+ "//some comment\n//another
comment\nmw.loader.load('//meta.wikimedia.org/w/" .
+
"index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
true,
'UserName',
'comments before the mw.loader.load call',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');\nsomeOtherJavaScript();",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+
"&action=raw&ctype=text/javascript');\nsomeOtherJavaScript();",
false,
'UserName',
'page contains some other javascript',
],
[
- "\n\n//some comment\n\n\n//another
comment\n\nmw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
+ "\n\n//some comment\n\n\n//another
comment\n\nmw.loader.load('//meta.wikimedia." .
+
"org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript');",
true,
'UserName',
'empty lines are also stripped in between
comments',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js&action=raw&ctype=text/javascript&smaxage=86400&maxage=86400');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:UserName/global.js"
.
+
"&action=raw&ctype=text/javascript&smaxage=86400&maxage=86400');",
true,
'UserName',
'(s)maxage parameters are accepted',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:John_F._Lewis/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:John_F._Lewis/" .
+
"global.js&action=raw&ctype=text/javascript');",
true,
'John F. Lewis',
'A username with spaces in it using
underscores',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester
(WMF)/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester
(WMF)/" .
+
"global.js&action=raw&ctype=text/javascript');",
true,
'Jdforrester (WMF)',
'A username with spaces in it using spaces',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester+(WMF)/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester+(WMF)/"
.
+
"global.js&action=raw&ctype=text/javascript');",
true,
'Jdforrester (WMF)',
'A username with spaces in it using +',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester%20(WMF)/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jdforrester%20(WMF)/"
.
+
"global.js&action=raw&ctype=text/javascript');",
true,
'Jdforrester (WMF)',
'A username with spaces in it using %20',
],
[
-
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:संतोष
दहिवळ/global.js&action=raw&ctype=text/javascript');",
+
"mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:संतोष
दहिवळ/global.js" .
+ "&action=raw&ctype=text/javascript');",
true,
'संतोष दहिवळ',
'A username with spaces and unicode!',
@@ -132,27 +150,32 @@
public static function provideCheckCss() {
return [
[
- "@import
url('//meta.wikimedia.org/w/index.php?title=User:UserName/global.css&action=raw&ctype=text/css');",
+ "@import
url('//meta.wikimedia.org/w/index.php?title=User:UserName/global.css" .
+ "&action=raw&ctype=text/css');",
true,
'standard @import with proto-rel'
],
[
- "@import
url('https://meta.wikimedia.org/w/index.php?title=User:UserName/global.css&action=raw&ctype=text/css');",
+ "@import
url('https://meta.wikimedia.org/w/index.php?title=User:UserName/" .
+
"global.css&action=raw&ctype=text/css');",
true,
'standard @import with https'
],
[
- "@import
url('//commons.wikimedia.org/w/index.php?title=User:UserName/global.css&action=raw&ctype=text/css');",
+ "@import
url('//commons.wikimedia.org/w/index.php?title=User:UserName/global.css" .
+ "&action=raw&ctype=text/css');",
false,
'loading from a different wiki'
],
[
- "@import
url('//meta.wikimedia.org/w/index.php?title=User:UserName/global.css&action=raw&ctype=text/css');\n
body{ background-color: red; }",
+ "@import
url('//meta.wikimedia.org/w/index.php?title=User:UserName/global.css" .
+ "&action=raw&ctype=text/css');\n body{
background-color: red; }",
false,
'some other CSS too',
],
[
- "@import
url('//meta.wikimedia.org/w/index.php?title=User:SomeOtherUserName/global.css&action=raw&ctype=text/css');",
+ "@import
url('//meta.wikimedia.org/w/index.php?title=User:SomeOtherUserName/" .
+
"global.css&action=raw&ctype=text/css');",
false,
'loading another user\'s CSS',
],
@@ -174,10 +197,26 @@
public static function provideNormalizeUserName() {
return [
- [ 'UserName', 'UserName', 'A regular name with no fancy
things' ],
- [ 'John F. Lewis', 'John( |_|\+|%20)F\.(
|_|\+|%20)Lewis', 'A name with spaces and a period' ],
- [ 'Jdforrester (WMF)', 'Jdforrester(
|_|\+|%20)\(WMF\)', 'A name with spaces and parenthesis' ],
- [ 'संतोष दहिवळ', 'संतोष( |_|\+|%20)दहिवळ', 'A name with
spaces and unicode' ],
+ [
+ 'UserName',
+ 'UserName',
+ 'A regular name with no fancy things'
+ ],
+ [
+ 'John F. Lewis',
+ 'John( |_|\+|%20)F\.( |_|\+|%20)Lewis',
+ 'A name with spaces and a period'
+ ],
+ [
+ 'Jdforrester (WMF)',
+ 'Jdforrester( |_|\+|%20)\(WMF\)',
+ 'A name with spaces and parenthesis'
+ ],
+ [
+ 'संतोष दहिवळ',
+ 'संतोष( |_|\+|%20)दहिवळ',
+ 'A name with spaces and unicode'
+ ],
];
}
--
To view, visit https://gerrit.wikimedia.org/r/364106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48b8b4389d7a9dbb2ae33d7c86defed56adda93c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalCssJs
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits