r89010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89009‎ | r89010 | r89011 >
Date:23:44, 27 May 2011
Author:wikinaut
Status:deferred (Comments)
Tags:
Comment:
added 2 hooks DeleteAccount, MergeAccountFromTo; changed function call parameters (added objects)
Modified paths:
  • /trunk/extensions/UserMerge/UserMerge.php (modified) (history)
  • /trunk/extensions/UserMerge/UserMerge_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserMerge/UserMerge_body.php
@@ -5,7 +5,7 @@
66
77 ///Special page class for the User Merge and Delete extension
88 /**
9 - * Special page that allows sysops to merge referances from one
 9+ * Special page that allows sysops to merge references from one
1010 * user to another user - also supports deleting users following
1111 * merge.
1212 *
@@ -155,9 +155,9 @@
156156 $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg( 'usermerge-badtoken' ) . "</span><br />\n" );
157157 } else {
158158 //good editToken
159 - $this->mergeUser( $newuser_text, $newuserID, $olduser_text, $olduserID );
 159+ $this->mergeUser( $objNewUser, $newuser_text, $newuserID, $objOldUser, $olduser_text, $olduserID );
160160 if ( $wgRequest->getText( 'deleteuser' ) ) {
161 - $this->deleteUser($olduserID, $olduser_text);
 161+ $this->deleteUser( $objOldUser, $olduserID, $olduser_text);
162162 }
163163 }
164164 }
@@ -172,7 +172,7 @@
173173 *
174174 * @return Always returns true - throws exceptions on failure.
175175 */
176 - private function deleteUser( $olduserID, $olduser_text ) {
 176+ private function deleteUser( $objOldUser, $olduserID, $olduser_text ) {
177177 global $wgOut,$wgUser;
178178
179179 $dbw = wfGetDB( DB_MASTER );
@@ -181,8 +181,10 @@
182182 $wgOut->addHTML( wfMsg( 'usermerge-userdeleted', $olduser_text, $olduserID ) );
183183
184184 $log = new LogPage( 'usermerge' );
185 - $log->addEntry( 'deleteuser', $wgUser->getUserPage(),'',array($olduser_text,$olduserID) );
 185+ $log->addEntry( 'deleteuser', $wgUser->getUserPage(), '', array( $olduser_text,$olduserID ) );
186186
 187+ wfRunHooks( 'DeleteAccount', array( $objOldUser ) );
 188+
187189 $users = $dbw->selectField( 'user', 'COUNT(*)', array() );
188190 $admins = $dbw->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ) );
189191 $dbw->update( 'site_stats',
@@ -191,19 +193,19 @@
192194 return true;
193195 }
194196
195 - ///Function to merge database referances from one user to another user
 197+ ///Function to merge database references from one user to another user
196198 /**
197199 * Merges database references from one user ID or username to another user ID or username
198200 * to preserve referential integrity.
199201 *
200 - * @param $newuser_text string Username to merge referances TO
201 - * @param $newuserID int ID of user to merge referances TO
202 - * @param $olduser_text string Username of user to remove referances FROM
203 - * @param $olduserID int ID of user to remove referances FROM
 202+ * @param $newuser_text string Username to merge references TO
 203+ * @param $newuserID int ID of user to merge references TO
 204+ * @param $olduser_text string Username of user to remove references FROM
 205+ * @param $olduserID int ID of user to remove references FROM
204206 *
205207 * @return Always returns true - throws exceptions on failure.
206208 */
207 - private function mergeUser( $newuser_text, $newuserID, $olduser_text, $olduserID ) {
 209+ private function mergeUser( $objNewUser, $newuser_text, $newuserID, $objOldUser, $olduser_text, $olduserID ) {
208210 global $wgOut, $wgUser;
209211
210212 $textUpdateFields = array(
@@ -248,6 +250,8 @@
249251 $log = new LogPage( 'usermerge' );
250252 $log->addEntry( 'mergeuser', $wgUser->getUserPage(),'',array($olduser_text,$olduserID,$newuser_text,$newuserID) );
251253
 254+ wfRunHooks( 'MergeAccountFromTo', array( $objOldUser, $objNewUser ) );
 255+
252256 return true;
253257 }
254258 }
Index: trunk/extensions/UserMerge/UserMerge.php
@@ -15,7 +15,7 @@
1616 'url' => 'http://www.mediawiki.org/wiki/Extension:User_Merge_and_Delete',
1717 'author' => 'Tim Laqua',
1818 'descriptionmsg' => 'usermerge-desc',
19 - 'version' => '1.6.1'
 19+ 'version' => '1.6.2'
2020 );
2121
2222 $wgAvailableRights[] = 'usermerge';

Comments

#Comment by Wikinaut (talk | contribs)   23:45, 27 May 2011

please code review !

Status & tagging log