r74566 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74565‎ | r74566 | r74567 >
Date:20:25, 9 October 2010
Author:soxred93
Status:ok
Tags:
Comment:
(bug 23812) AntiSpoof updates spoof table on user renaming
Modified paths:
  • /trunk/extensions/AntiSpoof/AntiSpoof.php (modified) (history)
  • /trunk/extensions/AntiSpoof/SpoofUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AntiSpoof/AntiSpoof.php
@@ -40,6 +40,7 @@
4141 $wgHooks['AbortNewAccount'][] = 'asAbortNewAccountHook';
4242 $wgHooks['UserCreateForm'][] = 'asUserCreateFormHook';
4343 $wgHooks['AddNewAccount'][] = 'asAddNewAccountHook';
 44+$wgHooks['RenameUserComplete'][] = 'asAddRenameUserHook';
4445
4546 function asUpdateSchema( $updater = null ) {
4647 if ( $updater === null ) {
@@ -130,3 +131,12 @@
131132 $spoof->record();
132133 return true;
133134 }
 135+
 136+/**
 137+ * On rename, remove the old entry and add the new
 138+ */
 139+function asAddRenameUserHook( $uid, $oldName, $newName ) {
 140+ $spoof = new SpoofUser( $newName );
 141+ $spoof->update( $oldName );
 142+ return true;
 143+}
Index: trunk/extensions/AntiSpoof/SpoofUser.php
@@ -102,4 +102,17 @@
103103 return false;
104104 }
105105 }
 106+
 107+ public function update( $oldName ) {
 108+
 109+ $dbw = wfGetDB( DB_MASTER );
 110+
 111+ if( $this->record() ) {
 112+ $dbw->delete(
 113+ 'spoofuser',
 114+ array( 'su_name' => $oldName ),
 115+ __METHOD__
 116+ );
 117+ }
 118+ }
106119 }

Status & tagging log