[MediaWiki-commits] [Gerrit] Add tests - change (mediawiki...Renameuser)

2015-10-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add tests
..


Add tests

* Fix all issues so tests pass.
* Rework out deprecated functions. Compatible with
  MediaWiki 1.23 and later.

Change-Id: I4545276d84fc0d0405d7c16ab179332298eb682b
---
M .gitignore
A .jshintignore
M Gruntfile.js
M RenameUserJob.php
M Renameuser.hooks.php
M Renameuser.php
M RenameuserLogFormatter.php
M RenameuserSQL.php
M cleanupArchiveUserText.php
A composer.json
M i18n/en.json
M package.json
A phpcs.xml
M renameUserCleanup.php
M specials/SpecialRenameuser.php
15 files changed, 339 insertions(+), 255 deletions(-)

Approvals:
  Paladox: Looks good to me, but someone else must approve
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.gitignore b/.gitignore
index 4bf4869..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
-.svn
 *~
 *.kate-swp
 .*.swp
 node_modules/
+/composer.lock
+/vendor/
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/Gruntfile.js b/Gruntfile.js
index 5a87e7b..116f582 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,10 +1,16 @@
 /*jshint node:true */
 module.exports = function ( grunt ) {
+   grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
 
var conf = grunt.file.readJSON( 'extension.json' );
grunt.initConfig( {
+   jshint: {
+   all: [
+   '*.js'
+   ]
+   },
banana: conf.MessagesDirs,
jsonlint: {
all: [
@@ -14,6 +20,6 @@
}
} );
 
-   grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
+   grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
 };
diff --git a/RenameUserJob.php b/RenameUserJob.php
index d2dc14c..2edfc44 100644
--- a/RenameUserJob.php
+++ b/RenameUserJob.php
@@ -1,4 +1,5 @@
 params['oldname'];
$userID = isset( $this->params['userID'] ) ? 
$this->params['userID'] : null;
$uidColumn = isset( $this->params['uidColumn'] ) ? 
$this->params['uidColumn'] : null;
-   $timestampColumn = isset( $this->params['timestampColumn'] ) ? 
$this->params['timestampColumn'] : null;
+   $timestampColumn = isset( $this->params['timestampColumn'] ) ?
+   $this->params['timestampColumn'] :
+   null;
$minTimestamp = $this->params['minTimestamp'];
$maxTimestamp = $this->params['maxTimestamp'];
$uniqueKey = isset( $this->params['uniqueKey'] ) ? 
$this->params['uniqueKey'] : null;
@@ -45,7 +48,7 @@
if ( isset( $timestampColumn ) ) {
$conds[] = "$timestampColumn >= '$minTimestamp'";
$conds[] = "$timestampColumn <= '$maxTimestamp'";
-   # Otherwise, bound by key (B/C)
+   # Otherwise, bound by key (B/C)
} elseif ( isset( $uniqueKey ) ) {
$conds[$uniqueKey] = $keyId;
} else {
@@ -59,7 +62,7 @@
__METHOD__
);
# Special case: revisions may be deleted while renaming...
-   if ( $table == 'revision' && isset( $timestampColumn ) ) {
+   if ( $table === 'revision' && isset( $timestampColumn ) ) {
$actual = $dbw->affectedRows();
# If some revisions were not renamed, they may have 
been deleted.
# Do a pass on the archive table to get these 
straglers...
@@ -77,7 +80,7 @@
}
}
# Special case: revisions may be restored while renaming...
-   if ( $table == 'archive' && isset( $timestampColumn ) ) {
+   if ( $table === 'archive' && isset( $timestampColumn ) ) {
$actual = $dbw->affectedRows();
# If some revisions were not renamed, they may have 
been restored.
# Do a pass on the revision table to get these 
straglers...
@@ -94,6 +97,7 @@
);
}
}
+
return true;
}
 }
diff --git a/Renameuser.hooks.php b/Renameuser.hooks.php
index 846f913..b344d99 100644
--- a/Renameuser.hooks.php
+++ b/Renameuser.hooks.php
@@ -11,9 +11,12 @@
public static function onShowMissingArticle( $article ) {
$title = $article->getTitle();
$oldUser = User::newFromName( $title->getBaseText() );
-   if ( ($title->getNamespace() == 

[MediaWiki-commits] [Gerrit] Add tests - change (mediawiki...Renameuser)

2015-10-02 Thread Siebrand (Code Review)
Siebrand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/243119

Change subject: Add tests
..

Add tests

Fix all issues so tests pass.

Change-Id: I4545276d84fc0d0405d7c16ab179332298eb682b
---
M .gitignore
M Gruntfile.js
M RenameUserJob.php
M Renameuser.hooks.php
M Renameuser.php
M RenameuserLogFormatter.php
M RenameuserSQL.php
M cleanupArchiveUserText.php
A composer.json
M i18n/en.json
A phpcs.xml
M renameUserCleanup.php
M specials/SpecialRenameuser.php
13 files changed, 318 insertions(+), 242 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Renameuser 
refs/changes/19/243119/1

diff --git a/.gitignore b/.gitignore
index 4bf4869..854a2d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
-.svn
 *~
 *.kate-swp
 .*.swp
 node_modules/
+/composer.lock
+/vendor/
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/RenameUserJob.php b/RenameUserJob.php
index d2dc14c..086678d 100644
--- a/RenameUserJob.php
+++ b/RenameUserJob.php
@@ -1,4 +1,5 @@
 params['oldname'];
$userID = isset( $this->params['userID'] ) ? 
$this->params['userID'] : null;
$uidColumn = isset( $this->params['uidColumn'] ) ? 
$this->params['uidColumn'] : null;
-   $timestampColumn = isset( $this->params['timestampColumn'] ) ? 
$this->params['timestampColumn'] : null;
+   $timestampColumn = isset( $this->params['timestampColumn'] ) ?
+   $this->params['timestampColumn'] :
+   null;
$minTimestamp = $this->params['minTimestamp'];
$maxTimestamp = $this->params['maxTimestamp'];
$uniqueKey = isset( $this->params['uniqueKey'] ) ? 
$this->params['uniqueKey'] : null;
@@ -45,7 +48,7 @@
if ( isset( $timestampColumn ) ) {
$conds[] = "$timestampColumn >= '$minTimestamp'";
$conds[] = "$timestampColumn <= '$maxTimestamp'";
-   # Otherwise, bound by key (B/C)
+   # Otherwise, bound by key (B/C)
} elseif ( isset( $uniqueKey ) ) {
$conds[$uniqueKey] = $keyId;
} else {
@@ -94,6 +97,7 @@
);
}
}
+
return true;
}
 }
diff --git a/Renameuser.hooks.php b/Renameuser.hooks.php
index 846f913..a9dfb01 100644
--- a/Renameuser.hooks.php
+++ b/Renameuser.hooks.php
@@ -11,9 +11,12 @@
public static function onShowMissingArticle( $article ) {
$title = $article->getTitle();
$oldUser = User::newFromName( $title->getBaseText() );
-   if ( ($title->getNamespace() == NS_USER || 
$title->getNamespace() == NS_USER_TALK ) && ($oldUser && $oldUser->isAnon() )) {
+   if ( ( $title->getNamespace() == NS_USER || 
$title->getNamespace() == NS_USER_TALK ) &&
+   ( $oldUser && $oldUser->isAnon() )
+   ) {
// Get the title for the base userpage
-   $page = Title::makeTitle( NS_USER, str_replace( ' ', 
'_', $title->getBaseText() ) )->getPrefixedDBkey();
+   $page = Title::makeTitle( NS_USER, str_replace( ' ', 
'_', $title->getBaseText() ) )
+   ->getPrefixedDBkey();
$out = $article->getContext()->getOutput();
LogEventsList::showLogExtract(
$out,
@@ -51,6 +54,7 @@
array( 'oldusername' => $nt->getText() )
);
}
+
return true;
}
 
@@ -61,6 +65,7 @@
 */
public static function onGetLogTypesOnUser( array &$types ) {
$types[] = 'renameuser';
+
return true;
}
 }
diff --git a/Renameuser.php b/Renameuser.php
index 441b571..738ca0d 100755
--- a/Renameuser.php
+++ b/Renameuser.php
@@ -5,10 +5,12 @@
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['Renameuser'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['RenameuserAliases'] = __DIR__ . 
'/Renameuser.alias.php';
+
/* wfWarn(
'Deprecated PHP entry point used for Renameuser extension. 
Please use wfLoadExtension instead, ' .
'see