SHARE
    TWEET
    Krenair

    CA global rename changes #2

    Feb 6th, 2013
    135
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Diff 7.91 KB | None | 0 0
    1. diff --git a/CentralAuth.i18n.php b/CentralAuth.i18n.php
    2. index 1d63842..5b38d75 100644
    3. --- a/CentralAuth.i18n.php
    4. +++ b/CentralAuth.i18n.php
    5. @@ -220,6 +220,7 @@ The passwords for local accounts created before the merge will revert to their p
    6. 'action-centralauth-globalrename' => 'globally rename a user',
    7. 'centralauth-globalrename-nonexistent' => 'Global account "<nowiki>1ドル</nowiki>" does not exist.',
    8. 'centralauth-globalrename-in-progress' => 'There is already a global rename in progress for <nowiki>1ドル</nowiki>.',
    9. + 'centralauth-globalrename-tempdisallowed' => 'Global account "<nowiki>1ドル</nowiki>" has more than 2ドル edits. Globally renaming such accounts has been temporarily disallowed while the code is experime
    10. // List of global users
    11. 'globalusers' => 'Global user list',
    12. @@ -747,6 +748,7 @@ See also:
    13. * 4ドル - the new username',
    14. 'right-centralauth-globalrename' => '{{doc-right|centralauth-globalrename}}',
    15. 'centralauth-globalrename-in-progress' => 'Error message shown when a global rename is already in progress on this username.',
    16. + 'centralauth-globalrename-tempdisallowed' => 'Error message shown when trying to rename a user with too many edits (default: 5000). This limitation will hopefully go away when we\'re happy with the
    17. );
    18. /** Afrikaans (Afrikaans)
    19. diff --git a/CentralAuthHooks.php b/CentralAuthHooks.php
    20. index ee9191f..7725528 100644
    21. --- a/CentralAuthHooks.php
    22. +++ b/CentralAuthHooks.php
    23. @@ -864,7 +864,11 @@ class CentralAuthHooks {
    24. * @param &$retval int a LoginForm class constant to return from authenticateUserData (default is LoginForm::ABORTED)
    25. */
    26. static function onAbortLogin( $user, $password, &$retval ) {
    27. - if ( !CentralAuthUser::getCentralDB()->lockIsFree( "centralauth-globalrename:" . $user->getName(), __METHOD__ ) ) {
    28. + global $wgMemc;
    29. + if (
    30. + !CentralAuthUser::getCentralDB()->lockIsFree( "centralauth-globalrename:" . $user->getName(), __METHOD__ ) ||
    31. + $wgMemc->get( CentralAuthUser::memcKey( 'globalrename', sha1( $user->getName() ) ) )
    32. + ) {
    33. $retval = LoginForm::ABORTED;
    34. return false;
    35. }
    36. diff --git a/LocalRenameUserJob.php b/LocalRenameUserJob.php
    37. index d1d117d..e67c068 100644
    38. --- a/LocalRenameUserJob.php
    39. +++ b/LocalRenameUserJob.php
    40. @@ -21,19 +21,13 @@ class CentralAuthLocalRenameUserJob extends Job {
    41. );
    42. if ( $rus->rename() ) {
    43. - // TODO: For renames of more than RENAMEUSER_CONTRIBJOB (default: 5000), this might need to take place in CentralAuthHooks::onRenameUserComplete
    44. - $wikiListKey = CentralAuthUser::memcKey( 'globalrename', sha1( $from ) );
    45. + // TODO: For renames of more than RENAMEUSER_CONTRIBJOB (default: 5000), we might want to do this in CentralAuthHooks::onRenameUserComplete instead
    46. + $wikiListKey = CentralAuthUser::memcKey( 'globalrename', sha1( $to ) );
    47. $wikiList = $wgMemc->get( $wikiListKey ); // TODO: Find a way to completely disable global renaming if memcache isn't available on all wikis. We can't just quit here if we see that
    48. $wikiList = array_diff( $wikiList, array( $wgDBname ) ); // Remove this wiki from the list.
    49. if ( count( $wikiList ) == 0 ) {
    50. $wgMemc->delete( $wikiListKey );
    51. - // Unlock the user
    52. - if ( !$this->params['startedLocked'] ) { // If the user was locked before we started renaming, we need to make sure we don't unlock them silently at the end.
    53. - $globalUser = new CentralAuthUser( $to );
    54. - $globalUser->adminUnlock();
    55. - }
    56. -
    57. // Make log entry on the wiki which this rename job was started on.
    58. $db = wfGetDB( DB_MASTER, array(), $this->params['startedFrom'] );
    59. $title = Title::newFromText( "User:{$from}@global" );
    60. diff --git a/specials/SpecialCentralAuth.php b/specials/SpecialCentralAuth.php
    61. index c1edb7a..e7b6be4 100644
    62. --- a/specials/SpecialCentralAuth.php
    63. +++ b/specials/SpecialCentralAuth.php
    64. @@ -25,7 +25,7 @@ class SpecialCentralAuth extends SpecialPage {
    65. $this->mCanOversight = $this->getUser()->isAllowed( 'centralauth-oversight' );
    66. $this->mCanEdit = $this->mCanUnmerge || $this->mCanLock || $this->mCanOversight;
    67. AutoLoader::loadClass( 'SpecialRenameuser' );
    68. - $this->mCanRename = $this->getUser()->isAllowed( 'centralauth-globalrename' ) && class_exists( 'SpecialRenameuser', false );
    69. + $this->mCanRename = $this->getUser()->isAllowed( 'centralauth-globalrename' ) && class_exists( 'RenameuserSQL', false ) && property_exists( 'RenameuserSQL', 'checkIfUserExists' );
    70. $this->getOutput()->addModules( 'ext.centralauth' );
    71. $this->getOutput()->addModuleStyles( 'ext.centralauth.noflash' );
    72. $this->getOutput()->addJsConfigVars( 'wgMergeMethodDescriptions', $this->getMergeMethodDescriptions() );
    73. @@ -217,6 +217,11 @@ class SpecialCentralAuth extends SpecialPage {
    74. return true;
    75. }
    76. + if ( $this->evaluateTotalEditcount() > RENAMEUSER_CONTRIBJOB ) {
    77. + $this->showError( 'centralauth-globalrename-tempdisallowed', $globalUser->getName(), RENAMEUSER_CONTRIBJOB );
    78. + return true;
    79. + }
    80. +
    81. $currentName = $globalUser->getName();
    82. $newName = $this->getRequest()->getText( 'newname' );
    83. @@ -241,12 +246,6 @@ class SpecialCentralAuth extends SpecialPage {
    84. $cdb->lock( "centralauth-globalrename:" . $currentName, __METHOD__ );
    85. $cdb->lock( "centralauth-globalrename:" . $newName, __METHOD__ );
    86. - $startedLocked = $globalUser->isLocked();
    87. - // Lock the user before we start changing anything.
    88. - if ( !$startedLocked ) {
    89. - $globalUser->adminLock();
    90. - }
    91. -
    92. // Update the globaluser and localuser tables. The existing hooks should deal with globalnames/localnames...
    93. $tables = array( 'globaluser' => 'gu', 'localuser' => 'lu' );
    94. foreach ( $tables as $table => $prefix ) {
    95. @@ -267,7 +266,6 @@ class SpecialCentralAuth extends SpecialPage {
    96. 'from' => $globalUser->getName(),
    97. 'to' => $newName,
    98. 'reason' => $this->getRequest()->getText( 'reason' ),
    99. - 'startedLocked' => $startedLocked,
    100. 'startedFrom' => $wgDBname,
    101. 'startedByName' => $this->getUser()->getName(),
    102. 'startedById' => $this->getUser()->getID(),
    103. @@ -276,7 +274,7 @@ class SpecialCentralAuth extends SpecialPage {
    104. );
    105. global $wgMemc;
    106. - $wgMemc->set( CentralAuthUser::memcKey( 'globalrename', sha1( $currentName ) ), $globalUser->listAttached() );
    107. + $wgMemc->set( CentralAuthUser::memcKey( 'globalrename', sha1( $newName ) ), $globalUser->listAttached() );
    108. // Put the job into the queue on each wiki it needs to run on
    109. foreach ( $globalUser->listAttached() as $wiki ) {
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /