[MediaWiki-commits] [Gerrit] mediawiki...CentralAuth[wmf/1.28.0-wmf.21]: Add ignorestatus option for fixing stuck renames

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

Change subject: Add ignorestatus option for fixing stuck renames
..


Add ignorestatus option for fixing stuck renames

Also fix log channel name.

Bug: T147029
Change-Id: I4f6f60a2525cfa50f951d40b8990eb43d2bf1b16
(cherry picked from commit a84a66c714f657417f9bb3c590e1ad98dffbe8e7)
---
M includes/LocalRenameJob/LocalRenameJob.php
M includes/LocalRenameJob/LocalRenameUserJob.php
M maintenance/fixStuckGlobalRename.php
3 files changed, 31 insertions(+), 7 deletions(-)

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



diff --git a/includes/LocalRenameJob/LocalRenameJob.php 
b/includes/LocalRenameJob/LocalRenameJob.php
index 5042f0f..26ea044 100644
--- a/includes/LocalRenameJob/LocalRenameJob.php
+++ b/includes/LocalRenameJob/LocalRenameJob.php
@@ -36,13 +36,16 @@
$factory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$factory->commitMasterChanges( $fnameTrxOwner );
 
-   if ( $status !== 'queued' && $status !== 'failed' ) {
-   LoggerFactory::getInstance( 'rename' )->info( 'skipping 
duplicate rename from {user}', [
-   'user' => $this->params['from'],
-   'to' => $this->params['to'],
-   'status' => $status,
-   ] );
-   return true;
+   if ( empty( $this->params['ignorestatus'] ) ) {
+   if ( $status !== 'queued' && $status !== 'failed' ) {
+   LoggerFactory::getInstance( 'CentralAuthRename' 
)
+   ->info( 'skipping duplicate rename from 
{user}', [
+   'user' => $this->params['from'],
+   'to' => $this->params['to'],
+   'status' => $status,
+   ] );
+   return true;
+   }
}
 
if ( isset( $this->params['session'] ) ) {
diff --git a/includes/LocalRenameJob/LocalRenameUserJob.php 
b/includes/LocalRenameJob/LocalRenameUserJob.php
index e6eb991..19365e6 100644
--- a/includes/LocalRenameJob/LocalRenameUserJob.php
+++ b/includes/LocalRenameJob/LocalRenameUserJob.php
@@ -7,6 +7,24 @@
  * This is intended to be run on each wiki individually
  */
 class LocalRenameUserJob extends LocalRenameJob {
+   /**
+* @param Title $title
+* @param array $params An associative array of options:
+*   from - old username
+*   to - new username
+*   force - try to do the rename even if the old username is invalid
+*   renamer - whom the renaming should be attributed in logs
+*   reason - reason to use in the rename log
+*   movepages - move user / user talk pages and their subpages
+*   suppressredirects - when moving pages, suppress redirects
+*   reattach - after rename, attach the local account. When used, 
should be set to
+* [ wiki ID => [ 'attachedMethod' => method, 'attachedTimestamp' 
=> timestamp ].
+* See CentralAuthUser::queryAttached. (default: false)
+*   promotetoglobal - globalize the new user account (default: false)
+*   session - session data from RequestContext::exportSession, for 
checkuser data
+*   ignorestatus - ignore update status, run the job even if it seems 
like another job
+* is already working on it
+*/
public function __construct( $title, $params ) {
$this->command = 'LocalRenameUserJob';
 
diff --git a/maintenance/fixStuckGlobalRename.php 
b/maintenance/fixStuckGlobalRename.php
index b4ddeb6..ccd34d3 100644
--- a/maintenance/fixStuckGlobalRename.php
+++ b/maintenance/fixStuckGlobalRename.php
@@ -16,6 +16,8 @@
$this->addArg( 'oldname', 'Old name' );
$this->addArg( 'newname', 'New name' );
$this->addOption( 'logwiki', 'Wiki where the log entry exists', 
true, true );
+   $this->addOption( 'ignorestatus', 'Ignore rename status. Don\'t 
do this when the rename '
+   . 'jobs might still be running.' );
$this->addDescription( 'Unstuck global rename on a single wiki' 
);
}
 
@@ -75,6 +77,7 @@
'movepages' => $movepages,
'suppressredirects' => $suppressredirects,
'reason' => $comment,
+   'ignorestatus' => $this->getOption( 'ignorestatus', 
false ),
// no way to recover localuser attachment details, 
faking it
'reattach' => [ wfWikiID() => [
'attachedMethod' => 

[MediaWiki-commits] [Gerrit] mediawiki...CentralAuth[wmf/1.28.0-wmf.21]: Add ignorestatus option for fixing stuck renames

2016-10-11 Thread Code Review
Gergő Tisza has uploaded a new change for review.

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

Change subject: Add ignorestatus option for fixing stuck renames
..

Add ignorestatus option for fixing stuck renames

Also fix log channel name.

Bug: T147029
Change-Id: I4f6f60a2525cfa50f951d40b8990eb43d2bf1b16
(cherry picked from commit a84a66c714f657417f9bb3c590e1ad98dffbe8e7)
---
M includes/LocalRenameJob/LocalRenameJob.php
M includes/LocalRenameJob/LocalRenameUserJob.php
M maintenance/fixStuckGlobalRename.php
3 files changed, 31 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/64/315364/1

diff --git a/includes/LocalRenameJob/LocalRenameJob.php 
b/includes/LocalRenameJob/LocalRenameJob.php
index 5042f0f..26ea044 100644
--- a/includes/LocalRenameJob/LocalRenameJob.php
+++ b/includes/LocalRenameJob/LocalRenameJob.php
@@ -36,13 +36,16 @@
$factory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$factory->commitMasterChanges( $fnameTrxOwner );
 
-   if ( $status !== 'queued' && $status !== 'failed' ) {
-   LoggerFactory::getInstance( 'rename' )->info( 'skipping 
duplicate rename from {user}', [
-   'user' => $this->params['from'],
-   'to' => $this->params['to'],
-   'status' => $status,
-   ] );
-   return true;
+   if ( empty( $this->params['ignorestatus'] ) ) {
+   if ( $status !== 'queued' && $status !== 'failed' ) {
+   LoggerFactory::getInstance( 'CentralAuthRename' 
)
+   ->info( 'skipping duplicate rename from 
{user}', [
+   'user' => $this->params['from'],
+   'to' => $this->params['to'],
+   'status' => $status,
+   ] );
+   return true;
+   }
}
 
if ( isset( $this->params['session'] ) ) {
diff --git a/includes/LocalRenameJob/LocalRenameUserJob.php 
b/includes/LocalRenameJob/LocalRenameUserJob.php
index e6eb991..19365e6 100644
--- a/includes/LocalRenameJob/LocalRenameUserJob.php
+++ b/includes/LocalRenameJob/LocalRenameUserJob.php
@@ -7,6 +7,24 @@
  * This is intended to be run on each wiki individually
  */
 class LocalRenameUserJob extends LocalRenameJob {
+   /**
+* @param Title $title
+* @param array $params An associative array of options:
+*   from - old username
+*   to - new username
+*   force - try to do the rename even if the old username is invalid
+*   renamer - whom the renaming should be attributed in logs
+*   reason - reason to use in the rename log
+*   movepages - move user / user talk pages and their subpages
+*   suppressredirects - when moving pages, suppress redirects
+*   reattach - after rename, attach the local account. When used, 
should be set to
+* [ wiki ID => [ 'attachedMethod' => method, 'attachedTimestamp' 
=> timestamp ].
+* See CentralAuthUser::queryAttached. (default: false)
+*   promotetoglobal - globalize the new user account (default: false)
+*   session - session data from RequestContext::exportSession, for 
checkuser data
+*   ignorestatus - ignore update status, run the job even if it seems 
like another job
+* is already working on it
+*/
public function __construct( $title, $params ) {
$this->command = 'LocalRenameUserJob';
 
diff --git a/maintenance/fixStuckGlobalRename.php 
b/maintenance/fixStuckGlobalRename.php
index b4ddeb6..ccd34d3 100644
--- a/maintenance/fixStuckGlobalRename.php
+++ b/maintenance/fixStuckGlobalRename.php
@@ -16,6 +16,8 @@
$this->addArg( 'oldname', 'Old name' );
$this->addArg( 'newname', 'New name' );
$this->addOption( 'logwiki', 'Wiki where the log entry exists', 
true, true );
+   $this->addOption( 'ignorestatus', 'Ignore rename status. Don\'t 
do this when the rename '
+   . 'jobs might still be running.' );
$this->addDescription( 'Unstuck global rename on a single wiki' 
);
}
 
@@ -75,6 +77,7 @@
'movepages' => $movepages,
'suppressredirects' => $suppressredirects,
'reason' => $comment,
+   'ignorestatus' => $this->getOption( 'ignorestatus', 
false ),
// no way to recover localuser attachment details, 
faking it
'reattach' => [ wfWikiID() => [