Krenair

CA global rename changes #2

Jan 31st, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.53 KB | None | 0 0
  1. diff --git a/CentralAuth.i18n.php b/CentralAuth.i18n.php
  2. index 07dec15..1d63842 100644
  3. --- a/CentralAuth.i18n.php
  4. +++ b/CentralAuth.i18n.php
  5. @@ -219,6 +219,7 @@ The passwords for local accounts created before the merge will revert to their p
  6.         'centralauth-globalrename-complete' => 'Global rename queued...',
  7.         'action-centralauth-globalrename' => 'globally rename a user',
  8.         'centralauth-globalrename-nonexistent' => 'Global account "<nowiki>$1</nowiki>" does not exist.',
  9. +       'centralauth-globalrename-in-progress' => 'There is already a global rename in progress for <nowiki>$1</nowiki>.',
  10.  
  11.         // List of global users
  12.         'globalusers'                    => 'Global user list',
  13. @@ -745,6 +746,7 @@ See also:
  14.         'centralauth-renameuser-globalrenameuser' => '{{Logentry}}
  15.  * $4 - the new username',
  16.         'right-centralauth-globalrename' => '{{doc-right|centralauth-globalrename}}',
  17. +       'centralauth-globalrename-in-progress' => 'Error message shown when a global rename is already in progress on this username.',
  18.  );
  19.  
  20.  /** Afrikaans (Afrikaans)
  21. diff --git a/LocalRenameUserJob.php b/LocalRenameUserJob.php
  22. index 7860654..d1d117d 100644
  23. --- a/LocalRenameUserJob.php
  24. +++ b/LocalRenameUserJob.php
  25. @@ -72,7 +72,9 @@ class CentralAuthLocalRenameUserJob extends Job {
  26.                                         ),
  27.                                         __METHOD__
  28.                                 );
  29. -                               CentralAuthUser::getCentralDB()->unlock( "centralauth-globalrename:" . $this->params['to'], __METHOD__ );
  30. +                               $cdb = CentralAuthUser::getCentralDB();
  31. +                               $cdb->unlock( "centralauth-globalrename:" . $this->params['from'], __METHOD__ );
  32. +                               $cdb->unlock( "centralauth-globalrename:" . $this->params['to'], __METHOD__ );
  33.                         } else {
  34.                                 $wgMemc->set( $wikiListKey, $wikiList );
  35.                         }
  36. diff --git a/specials/SpecialCentralAuth.php b/specials/SpecialCentralAuth.php
  37. index a289f23..c1edb7a 100644
  38. --- a/specials/SpecialCentralAuth.php
  39. +++ b/specials/SpecialCentralAuth.php
  40. @@ -233,14 +233,20 @@ class SpecialCentralAuth extends SpecialPage {
  41.                                 return true;
  42.                         }
  43.  
  44. +                       $cdb = CentralAuthUser::getCentralDB();
  45. +                       if ( !$cdb->lockIsFree( 'centralauth-globalrename:' . $currentName, __METHOD__ ) ) {
  46. +                               $this->showError( 'centralauth-globalrename-in-progress', $currentName );
  47. +                               return true;
  48. +                       }
  49. +                       $cdb->lock( "centralauth-globalrename:" . $currentName, __METHOD__ );
  50. +                       $cdb->lock( "centralauth-globalrename:" . $newName, __METHOD__ );
  51. +
  52.                         $startedLocked = $globalUser->isLocked();
  53.                         // Lock the user before we start changing anything.
  54.                         if ( !$startedLocked ) {
  55.                                 $globalUser->adminLock();
  56.                         }
  57.  
  58. -                       CentralAuthUser::getCentralDB()->lock( "centralauth-globalrename:" . $newName, __METHOD__ );
  59. -
  60.                         // Update the globaluser and localuser tables. The existing hooks should deal with globalnames/localnames...
  61.                         $tables = array( 'globaluser' => 'gu', 'localuser' => 'lu' );
  62.                         foreach ( $tables as $table => $prefix ) {
Advertisement
Add Comment
Please, Sign In to add comment