Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/243117
Change subject: Add tests
......................................................................
Add tests
Fix all issues so tests pass.
Change-Id: I08a0be7df48f9a39951cdc4edd4091fd4b89eade
---
M .gitignore
M .jshintrc
M Gruntfile.js
M Nuke.hooks.php
M Nuke.php
M Nuke_body.php
M SpecialNuke.php
A composer.json
M i18n/en.json
A phpcs.xml
10 files changed, 106 insertions(+), 68 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Nuke
refs/changes/17/243117/1
diff --git a/.gitignore b/.gitignore
index 49af909..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,6 @@
-.*
*~
*.kate-swp
.*.swp
-
-!.gitignore
-!.gitreview
-!.jshintrc
node_modules/
+/composer.lock
+/vendor/
diff --git a/.jshintrc b/.jshintrc
index f274a67..946c003 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -2,7 +2,6 @@
"predef": [
"jQuery"
],
-
/* Common */
// Enforcing
@@ -19,7 +18,6 @@
"trailing": true,
"undef": true,
"unused": true,
-
// Environment
"browser": true
}
diff --git a/Gruntfile.js b/Gruntfile.js
index 5a87e7b..9c56558 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -3,9 +3,10 @@
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
- var conf = grunt.file.readJSON( 'extension.json' );
grunt.initConfig( {
- banana: conf.MessagesDirs,
+ banana: {
+ all: 'i18n/'
+ },
jsonlint: {
all: [
'**/*.json',
diff --git a/Nuke.hooks.php b/Nuke.hooks.php
index fddcf51..40a1a43 100644
--- a/Nuke.hooks.php
+++ b/Nuke.hooks.php
@@ -22,6 +22,7 @@
array( 'target' => $userPageTitle->getText() )
);
}
+
return true;
}
}
diff --git a/Nuke.php b/Nuke.php
index ec37f1c..56a9f3b 100644
--- a/Nuke.php
+++ b/Nuke.php
@@ -5,10 +5,12 @@
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['Nuke'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['NukeAlias'] = __DIR__ . '/Nuke.alias.php';
+
/* wfWarn(
'Deprecated PHP entry point used for Nuke extension. Please use
wfLoadExtension instead, ' .
'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
); */
+
return true;
} else {
die( 'This version of the Nuke extension requires MediaWiki 1.25+' );
diff --git a/Nuke_body.php b/Nuke_body.php
index b662b7f..8458db5 100644
--- a/Nuke_body.php
+++ b/Nuke_body.php
@@ -38,7 +38,7 @@
$msg = $target === '' ?
$this->msg( 'nuke-multiplepeople'
)->inContentLanguage()->text() :
$this->msg( 'nuke-defaultreason', $target )->
- inContentLanguage()->text();
+ inContentLanguage()->text();
$reason = $req->getText( 'wpReason', $msg );
$limit = $req->getInt( 'limit', 500 );
@@ -46,16 +46,18 @@
$namespace = ctype_digit( $namespace ) ? (int)$namespace : null;
if ( $req->wasPosted()
- && $this->getUser()->matchEditToken( $req->getVal(
'wpEditToken' ) ) ) {
+ && $this->getUser()->matchEditToken( $req->getVal(
'wpEditToken' ) )
+ ) {
- if ( $req->getVal( 'action' ) == 'delete' ) {
+ if ( $req->getVal( 'action' ) === 'delete' ) {
$pages = $req->getArray( 'pages' );
if ( $pages ) {
$this->doDelete( $pages, $reason );
+
return;
}
- } elseif ( $req->getVal( 'action' ) == 'submit' ) {
+ } elseif ( $req->getVal( 'action' ) === 'submit' ) {
$this->listForm( $target, $reason, $limit,
$namespace );
} else {
$this->promptForm();
@@ -82,25 +84,37 @@
Xml::openElement(
'form',
array(
- 'action' =>
$this->getTitle()->getLocalURL( 'action=submit' ),
+ 'action' =>
$this->getPageTitle()->getLocalURL( 'action=submit' ),
'method' => 'post'
)
)
. '<table><tr>'
- . '<td>' . Xml::label( $this->msg(
'nuke-userorip' )->text(), 'nuke-target' ) . '</td>'
- . '<td>' . Xml::input( 'target', 40, $userName,
array( 'id' => 'nuke-target', 'class' => 'mw-autocomplete-user', 'autofocus' =>
true ) ) . '</td>'
+ . '<td>' . Xml::label( $this->msg( 'nuke-userorip'
)->text(), 'nuke-target' ) . '</td>'
+ . '<td>' . Xml::input(
+ 'target',
+ 40,
+ $userName,
+ array(
+ 'id' => 'nuke-target',
+ 'class' => 'mw-autocomplete-user',
+ 'autofocus' => true
+ )
+ ) . '</td>'
. '</tr><tr>'
- . '<td>' . Xml::label( $this->msg(
'nuke-pattern' )->text(), 'nuke-pattern' ) . '</td>'
- . '<td>' . Xml::input( 'pattern', 40, '',
array( 'id' => 'nuke-pattern' ) ) . '</td>'
- . '</tr><tr>'
- . '<td>' . Xml::label( $this->msg(
'nuke-namespace' )->text(), 'nuke-namespace' ) . '</td>'
- . '<td>' . Html::namespaceSelector( array(
'all' => 'all' ), array( 'name' => 'namespace' ) ) . '</td>'
+ . '<td>' . Xml::label( $this->msg( 'nuke-pattern'
)->text(), 'nuke-pattern' ) . '</td>'
+ . '<td>' . Xml::input( 'pattern', 40, '', array( 'id'
=> 'nuke-pattern' ) ) . '</td>'
. '</tr><tr>'
- . '<td>' . Xml::label( $this->msg(
'nuke-maxpages' )->text(), 'nuke-limit' ) . '</td>'
- . '<td>' . Xml::input( 'limit', 7, '500',
array( 'id' => 'nuke-limit' ) ) . '</td>'
+ . '<td>' . Xml::label( $this->msg( 'nuke-namespace'
)->text(), 'nuke-namespace' ) . '</td>'
+ . '<td>' . Html::namespaceSelector(
+ array( 'all' => 'all' ),
+ array( 'name' => 'namespace' )
+ ) . '</td>'
. '</tr><tr>'
- . '<td></td>'
- . '<td>' . Xml::submitButton( $this->msg(
'nuke-submit-user' )->text() ) . '</td>'
+ . '<td>' . Xml::label( $this->msg( 'nuke-maxpages'
)->text(), 'nuke-limit' ) . '</td>'
+ . '<td>' . Xml::input( 'limit', 7, '500', array( 'id'
=> 'nuke-limit' ) ) . '</td>'
+ . '</tr><tr>'
+ . '<td></td>'
+ . '<td>' . Xml::submitButton( $this->msg(
'nuke-submit-user' )->text() ) . '</td>'
. '</tr></table>'
. Html::hidden( 'wpEditToken',
$this->getUser()->getEditToken() )
. Xml::closeElement( 'form' )
@@ -120,7 +134,7 @@
$pages = $this->getNewPages( $username, $limit, $namespace );
- if ( count( $pages ) == 0 ) {
+ if ( count( $pages ) === 0 ) {
if ( $username === '' ) {
$out->addWikiMsg( 'nuke-nopages-global' );
} else {
@@ -128,6 +142,7 @@
}
$this->promptForm( $username );
+
return;
}
@@ -137,15 +152,15 @@
$out->addWikiMsg( 'nuke-list', $username );
}
- $nuke = $this->getTitle();
+ $nuke = $this->getPageTitle();
$out->addModules( 'ext.nuke' );
$out->addHTML(
Xml::openElement( 'form', array(
- 'action' => $nuke->getLocalURL( 'action=delete'
),
- 'method' => 'post',
- 'name' => 'nukelist' )
+ 'action' => $nuke->getLocalURL(
'action=delete' ),
+ 'method' => 'post',
+ 'name' => 'nukelist' )
) .
Html::hidden( 'wpEditToken',
$this->getUser()->getEditToken() ) .
Xml::tags( 'p',
@@ -188,10 +203,14 @@
*/
list( $title, $userName ) = $info;
- $image = $title->getNamespace() == NS_IMAGE ?
wfLocalFile( $title ) : false;
- $thumb = $image && $image->exists() ?
$image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false;
+ $image = $title->getNamespace() === NS_IMAGE ?
wfLocalFile( $title ) : false;
+ $thumb = $image && $image->exists() ?
+ $image->transform( array( 'width' => 120,
'height' => 120 ), 0 ) :
+ false;
- $userNameText = $userName ? $this->msg( 'nuke-editby',
$userName )->parse() . $commaSeparator : '';
+ $userNameText = $userName ?
+ $this->msg( 'nuke-editby', $userName )->parse()
. $commaSeparator :
+ '';
$changesLink = Linker::linkKnown(
$title,
$this->msg( 'nuke-viewchanges' )->escaped(),
@@ -202,7 +221,7 @@
Xml::check(
'pages[]',
true,
- array( 'value' =>
$title->getPrefixedDbKey() )
+ array( 'value' =>
$title->getPrefixedDBKey() )
) . ' ' .
( $thumb ? $thumb->toHtml( array( 'desc-link'
=> true ) ) : '' ) .
Linker::linkKnown( $title ) . $wordSeparator .
@@ -288,7 +307,7 @@
foreach ( $pages as $page ) {
$title = Title::newFromURL( $page );
- $file = $title->getNamespace() == NS_FILE ?
wfLocalFile( $title ) : false;
+ $file = $title->getNamespace() === NS_FILE ?
wfLocalFile( $title ) : false;
$permission_errors = $title->getUserPermissionsErrors(
'delete', $this->getUser() );
diff --git a/SpecialNuke.php b/SpecialNuke.php
index 3a8408a..a618a33 100644
--- a/SpecialNuke.php
+++ b/SpecialNuke.php
@@ -1,2 +1,2 @@
<?php
-require_once( __DIR__ . '/Nuke.php' );
+require_once __DIR__ . '/Nuke.php';
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..4365e8a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,12 @@
+{
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
+ },
+ "scripts": {
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
+ ]
+ }
+}
diff --git a/i18n/en.json b/i18n/en.json
index 8648868..b6b8c0d 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,34 +1,34 @@
{
- "@metadata": {
- "authors": [
- "Brion Vibber",
- "Jeroen De Dauw"
- ]
- },
- "nuke": "Mass delete",
- "action-nuke": "nuke pages",
- "nuke-desc": "Gives administrators the ability to [[Special:Nuke|mass
delete]] pages",
- "nuke-nopages": "No new pages by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]] in recent changes.",
- "nuke-list": "The following pages were recently created by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]];\nput in a comment and hit the
button to delete them.",
- "nuke-list-multiple": "The following pages were recently created;\nput in
a comment and hit the button to delete them.",
- "nuke-defaultreason": "Mass deletion of pages added by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
- "nuke-multiplepeople": "Mass deletion of recently added pages",
- "nuke-tools": "This tool allows for mass deletions of pages recently added
by a given user or an IP address.\nInput the username or IP address to get a
list of pages to delete, or leave blank for all users.",
- "nuke-submit-user": "Go",
- "nuke-toggleinvert": "Invert",
- "nuke-submit-delete": "Delete selected",
- "right-nuke": "Mass delete pages",
- "nuke-select": "Select: $1",
- "nuke-userorip": "Username, IP address or blank:",
- "nuke-maxpages": "Maximum number of pages:",
- "nuke-editby": "Created by [[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
- "nuke-deleted": "Page '''$1''' has been deleted.",
- "nuke-not-deleted": "Page [[:$1]] '''could not''' be deleted.",
- "nuke-delete-more": "[[Special:Nuke|Delete more pages]]",
- "nuke-pattern": "Pattern for the page name:",
- "nuke-nopages-global": "There are no new pages in
[[Special:RecentChanges|recent changes]].",
- "nuke-viewchanges": "view changes",
- "nuke-namespace": "Limit to namespace:",
- "nuke-linkoncontribs": "mass delete",
- "nuke-linkoncontribs-text": "Mass delete pages where this user is the only
author"
+ "@metadata": {
+ "authors": [
+ "Brion Vibber",
+ "Jeroen De Dauw"
+ ]
+ },
+ "nuke": "Mass delete",
+ "action-nuke": "nuke pages",
+ "nuke-desc": "Gives administrators the ability to [[Special:Nuke|mass
delete]] pages",
+ "nuke-nopages": "No new pages by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]] in recent changes.",
+ "nuke-list": "The following pages were recently created by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]];\nput in a comment and hit the
button to delete them.",
+ "nuke-list-multiple": "The following pages were recently created;\nput
in a comment and hit the button to delete them.",
+ "nuke-defaultreason": "Mass deletion of pages added by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
+ "nuke-multiplepeople": "Mass deletion of recently added pages",
+ "nuke-tools": "This tool allows for mass deletions of pages recently
added by a given user or an IP address.\nInput the username or IP address to
get a list of pages to delete, or leave blank for all users.",
+ "nuke-submit-user": "Go",
+ "nuke-toggleinvert": "Invert",
+ "nuke-submit-delete": "Delete selected",
+ "right-nuke": "Mass delete pages",
+ "nuke-select": "Select: $1",
+ "nuke-userorip": "Username, IP address or blank:",
+ "nuke-maxpages": "Maximum number of pages:",
+ "nuke-editby": "Created by
[[Special:Contributions/$1|{{GENDER:$1|$1}}]]",
+ "nuke-deleted": "Page '''$1''' has been deleted.",
+ "nuke-not-deleted": "Page [[:$1]] '''could not''' be deleted.",
+ "nuke-delete-more": "[[Special:Nuke|Delete more pages]]",
+ "nuke-pattern": "Pattern for the page name:",
+ "nuke-nopages-global": "There are no new pages in
[[Special:RecentChanges|recent changes]].",
+ "nuke-viewchanges": "view changes",
+ "nuke-namespace": "Limit to namespace:",
+ "nuke-linkoncontribs": "mass delete",
+ "nuke-linkoncontribs-text": "Mass delete pages where this user is the
only author"
}
\ No newline at end of file
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+</ruleset>
--
To view, visit https://gerrit.wikimedia.org/r/243117
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I08a0be7df48f9a39951cdc4edd4091fd4b89eade
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Nuke
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits