Index: trunk/extensions/Renameuser/RenameUserJob.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Custom job to perform updates on tables in busier environments |
6 | 5 | */ |
— | — | @@ -26,15 +25,15 @@ |
27 | 26 | # Conditions like "*_user_text = 'x' |
28 | 27 | $conds = array( $column => $oldname ); |
29 | 28 | # If user ID given, add that to condition to avoid rename collisions. |
30 | | - if( isset($userID) ) { |
| 29 | + if ( isset( $userID ) ) { |
31 | 30 | $conds[$uidColumn] = $userID; |
32 | 31 | } |
33 | 32 | # Bound by timestamp if given |
34 | | - if( isset($timestampColumn) ) { |
| 33 | + if ( isset( $timestampColumn ) ) { |
35 | 34 | $conds[] = "$timestampColumn >= '$minTimestamp'"; |
36 | 35 | $conds[] = "$timestampColumn <= '$maxTimestamp'"; |
37 | 36 | # Otherwise, bound by key (B/C) |
38 | | - } else if( isset($uniqueKey) ) { |
| 37 | + } else if ( isset( $uniqueKey ) ) { |
39 | 38 | $conds[$uniqueKey] = $keyId; |
40 | 39 | } else { |
41 | 40 | wfDebug( 'RenameUserJob::run - invalid job row given' ); // this shouldn't happen |
— | — | @@ -47,11 +46,11 @@ |
48 | 47 | __METHOD__ |
49 | 48 | ); |
50 | 49 | # Special case: revisions may be deleted while renaming... |
51 | | - if( $table == 'revision' && isset($timestampColumn) ) { |
| 50 | + if ( $table == 'revision' && isset( $timestampColumn ) ) { |
52 | 51 | $actual = $dbw->affectedRows(); |
53 | 52 | # If some revisions were not renamed, they may have been deleted. |
54 | 53 | # Do a pass on the archive table to get these straglers... |
55 | | - if( $actual < $count ) { |
| 54 | + if ( $actual < $count ) { |
56 | 55 | $dbw->update( 'archive', |
57 | 56 | array( 'ar_user_text' => $newname ), |
58 | 57 | array( 'ar_user_text' => $oldname, |
— | — | @@ -59,17 +58,17 @@ |
60 | 59 | // No user,rev_id index, so use timestamp to bound |
61 | 60 | // the rows. This can use the user,timestamp index. |
62 | 61 | "ar_timestamp >= '$minTimestamp'", |
63 | | - "ar_timestamp <= '$maxTimestamp'"), |
| 62 | + "ar_timestamp <= '$maxTimestamp'" ), |
64 | 63 | __METHOD__ |
65 | 64 | ); |
66 | 65 | } |
67 | 66 | } |
68 | 67 | # Special case: revisions may be restored while renaming... |
69 | | - if( $table == 'archive' && isset($timestampColumn) ) { |
| 68 | + if ( $table == 'archive' && isset( $timestampColumn ) ) { |
70 | 69 | $actual = $dbw->affectedRows(); |
71 | 70 | # If some revisions were not renamed, they may have been restored. |
72 | 71 | # Do a pass on the revision table to get these straglers... |
73 | | - if( $actual < $count ) { |
| 72 | + if ( $actual < $count ) { |
74 | 73 | $dbw->update( 'revision', |
75 | 74 | array( 'rev_user_text' => $newname ), |
76 | 75 | array( 'rev_user_text' => $oldname, |
— | — | @@ -77,12 +76,11 @@ |
78 | 77 | // No user,rev_id index, so use timestamp to bound |
79 | 78 | // the rows. This can use the user,timestamp index. |
80 | 79 | "rev_timestamp >= '$minTimestamp'", |
81 | | - "rev_timestamp <= '$maxTimestamp'"), |
| 80 | + "rev_timestamp <= '$maxTimestamp'" ), |
82 | 81 | __METHOD__ |
83 | 82 | ); |
84 | 83 | } |
85 | 84 | } |
86 | 85 | return true; |
87 | 86 | } |
88 | | - |
89 | | -} |
\ No newline at end of file |
| 87 | +} |
Index: trunk/extensions/Renameuser/Renameuser_body.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | if ( !defined( 'MEDIAWIKI' ) ) { |
5 | 4 | echo "RenameUser extension\n"; |
6 | 5 | exit( 1 ); |
— | — | @@ -13,7 +12,6 @@ |
14 | 13 | * user accounts |
15 | 14 | */ |
16 | 15 | class SpecialRenameuser extends SpecialPage { |
17 | | - |
18 | 16 | /** |
19 | 17 | * Constructor |
20 | 18 | */ |
— | — | @@ -33,11 +31,11 @@ |
34 | 32 | $this->setHeaders(); |
35 | 33 | $wgOut->addWikiMsg( 'renameuser-summary' ); |
36 | 34 | |
37 | | - if( !$wgUser->isAllowed( 'renameuser' ) ) { |
| 35 | + if ( !$wgUser->isAllowed( 'renameuser' ) ) { |
38 | 36 | $wgOut->permissionRequired( 'renameuser' ); |
39 | 37 | return; |
40 | 38 | } |
41 | | - if( wfReadOnly() ) { |
| 39 | + if ( wfReadOnly() ) { |
42 | 40 | $wgOut->readOnlyPage(); |
43 | 41 | return; |
44 | 42 | } |
— | — | @@ -54,13 +52,13 @@ |
55 | 53 | // If nothing given for these flags, assume they are checked |
56 | 54 | // unless this is a POST submission. |
57 | 55 | $move_checked = true; |
58 | | - if( $wgRequest->wasPosted() ) { |
59 | | - if( !$wgRequest->getCheck( 'movepages' ) ) { |
| 56 | + if ( $wgRequest->wasPosted() ) { |
| 57 | + if ( !$wgRequest->getCheck( 'movepages' ) ) { |
60 | 58 | $move_checked = false; |
61 | 59 | } |
62 | 60 | } |
63 | 61 | $warnings = array(); |
64 | | - if( $oun && $nun && !$wgRequest->getCheck( 'confirmaction' ) ) { |
| 62 | + if ( $oun && $nun && !$wgRequest->getCheck( 'confirmaction' ) ) { |
65 | 63 | wfRunHooks( 'RenameUserWarning', array( $oun, $nun, &$warnings ) ); |
66 | 64 | } |
67 | 65 | |
— | — | @@ -95,21 +93,21 @@ |
96 | 94 | "</td> |
97 | 95 | </tr>" |
98 | 96 | ); |
99 | | - if( $wgUser->isAllowed( 'move' ) ) { |
| 97 | + if ( $wgUser->isAllowed( 'move' ) ) { |
100 | 98 | $wgOut->addHTML( " |
101 | 99 | <tr> |
102 | 100 | <td> |
103 | 101 | </td> |
104 | 102 | <td class='mw-input'>" . |
105 | | - Xml::checkLabel( wfMsg( 'renameusermove' ), 'movepages', 'movepages', |
| 103 | + Xml::checkLabel( wfMsg( 'renameusermove' ), 'movepages', 'movepages', |
106 | 104 | $move_checked, array( 'tabindex' => '4' ) ) . |
107 | 105 | "</td> |
108 | 106 | </tr>" |
109 | 107 | ); |
110 | 108 | } |
111 | | - if( $warnings ) { |
| 109 | + if ( $warnings ) { |
112 | 110 | $warningsHtml = array(); |
113 | | - foreach( $warnings as $warning ) |
| 111 | + foreach ( $warnings as $warning ) |
114 | 112 | $warningsHtml[] = is_array( $warning ) ? |
115 | 113 | call_user_func_array( 'wfMsgWikiHtml', $warning ) : |
116 | 114 | wfMsgHtml( $warning ); |
— | — | @@ -118,8 +116,8 @@ |
119 | 117 | <td class='mw-label'>" . wfMsgWikiHtml( 'renameuserwarnings' ) . " |
120 | 118 | </td> |
121 | 119 | <td class='mw-input'>" . |
122 | | - '<ul style="color: red; font-weight: bold"><li>'. |
123 | | - implode( '</li><li>', $warningsHtml ).'</li></ul>'. |
| 120 | + '<ul style="color: red; font-weight: bold"><li>' . |
| 121 | + implode( '</li><li>', $warningsHtml ) . '</li></ul>' . |
124 | 122 | "</td> |
125 | 123 | </tr>" |
126 | 124 | ); |
— | — | @@ -128,7 +126,7 @@ |
129 | 127 | <td> |
130 | 128 | </td> |
131 | 129 | <td class='mw-input'>" . |
132 | | - Xml::checkLabel( wfMsg( 'renameuserconfirm' ), 'confirmaction', 'confirmaction', |
| 130 | + Xml::checkLabel( wfMsg( 'renameuserconfirm' ), 'confirmaction', 'confirmaction', |
133 | 131 | false, array( 'tabindex' => '6' ) ) . |
134 | 132 | "</td> |
135 | 133 | </tr>" |
— | — | @@ -139,10 +137,10 @@ |
140 | 138 | <td> |
141 | 139 | </td> |
142 | 140 | <td class='mw-submit'>" . |
143 | | - Xml::submitButton( wfMsg( 'renameusersubmit' ), array( 'name' => 'submit', |
| 141 | + Xml::submitButton( wfMsg( 'renameusersubmit' ), array( 'name' => 'submit', |
144 | 142 | 'tabindex' => '7', 'id' => 'submit' ) ) . |
145 | 143 | ' ' . |
146 | | - Xml::submitButton( wfMsg( 'blocklogpage' ), array ( 'name' => 'submit-showBlockLog', |
| 144 | + Xml::submitButton( wfMsg( 'blocklogpage' ), array ( 'name' => 'submit-showBlockLog', |
147 | 145 | 'id' => 'submit-showBlockLog', 'tabindex' => '8' ) ) . |
148 | 146 | "</td> |
149 | 147 | </tr>" . |
— | — | @@ -153,35 +151,35 @@ |
154 | 152 | ); |
155 | 153 | |
156 | 154 | // Show block log if requested |
157 | | - if( $showBlockLog && is_object( $oldusername ) ) { |
| 155 | + if ( $showBlockLog && is_object( $oldusername ) ) { |
158 | 156 | $this->showLogExtract( $oldusername, 'block', $wgOut ) ; |
159 | 157 | return; |
160 | 158 | } |
161 | 159 | |
162 | | - if( $wgRequest->getText( 'token' ) === '' ) { |
| 160 | + if ( $wgRequest->getText( 'token' ) === '' ) { |
163 | 161 | # They probably haven't even submitted the form, so don't go further. |
164 | 162 | return; |
165 | | - } elseif( $warnings ) { |
| 163 | + } elseif ( $warnings ) { |
166 | 164 | # Let user read warnings |
167 | 165 | return; |
168 | | - } elseif( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
| 166 | + } elseif ( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
169 | 167 | $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameuser-error-request' ) . "</div>" ); |
170 | 168 | return; |
171 | | - } elseif( !is_object( $oldusername ) ) { |
| 169 | + } elseif ( !is_object( $oldusername ) ) { |
172 | 170 | $wgOut->addWikiText( |
173 | 171 | "<div class=\"errorbox\">" |
174 | 172 | . wfMsg( 'renameusererrorinvalid', $wgRequest->getText( 'oldusername' ) ) |
175 | 173 | . "</div>" |
176 | 174 | ); |
177 | 175 | return; |
178 | | - } elseif( !is_object( $newusername ) ) { |
| 176 | + } elseif ( !is_object( $newusername ) ) { |
179 | 177 | $wgOut->addWikiText( |
180 | 178 | "<div class=\"errorbox\">" |
181 | 179 | . wfMsg( 'renameusererrorinvalid', $wgRequest->getText( 'newusername' ) ) |
182 | 180 | . "</div>" |
183 | 181 | ); |
184 | 182 | return; |
185 | | - } elseif( $oldusername->getText() == $newusername->getText() ) { |
| 183 | + } elseif ( $oldusername->getText() == $newusername->getText() ) { |
186 | 184 | $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameuser-error-same-user' ) . "</div>" ); |
187 | 185 | return; |
188 | 186 | } |
— | — | @@ -191,27 +189,27 @@ |
192 | 190 | $newuser = User::newFromName( $newusername->getText(), 'creatable' ); |
193 | 191 | |
194 | 192 | // It won't be an object if for instance "|" is supplied as a value |
195 | | - if( !is_object( $olduser ) ) { |
196 | | - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid', |
| 193 | + if ( !is_object( $olduser ) ) { |
| 194 | + $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid', |
197 | 195 | $oldusername->getText() ) . "</div>" ); |
198 | 196 | return; |
199 | 197 | } |
200 | | - if( !is_object( $newuser ) || !User::isCreatableName( $newuser->getName() ) ) { |
201 | | - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid', |
| 198 | + if ( !is_object( $newuser ) || !User::isCreatableName( $newuser->getName() ) ) { |
| 199 | + $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorinvalid', |
202 | 200 | $newusername->getText() ) . "</div>" ); |
203 | 201 | return; |
204 | 202 | } |
205 | 203 | |
206 | 204 | // Check for the existence of lowercase oldusername in database. |
207 | 205 | // Until r19631 it was possible to rename a user to a name with first character as lowercase |
208 | | - if( $oldusername->getText() !== $wgContLang->ucfirst( $oldusername->getText() ) ) { |
| 206 | + if ( $oldusername->getText() !== $wgContLang->ucfirst( $oldusername->getText() ) ) { |
209 | 207 | // oldusername was entered as lowercase -> check for existence in table 'user' |
210 | 208 | $dbr = wfGetDB( DB_SLAVE ); |
211 | | - $uid = $dbr->selectField( 'user', 'user_id', |
212 | | - array( 'user_name' => $oldusername->getText() ), |
| 209 | + $uid = $dbr->selectField( 'user', 'user_id', |
| 210 | + array( 'user_name' => $oldusername->getText() ), |
213 | 211 | __METHOD__ ); |
214 | | - if( $uid === false ) { |
215 | | - if( !$wgCapitalLinks ) { |
| 212 | + if ( $uid === false ) { |
| 213 | + if ( !$wgCapitalLinks ) { |
216 | 214 | $uid = 0; // We are on a lowercase wiki but lowercase username does not exists |
217 | 215 | } else { |
218 | 216 | // We are on a standard uppercase wiki, use normal |
— | — | @@ -224,14 +222,14 @@ |
225 | 223 | $uid = $olduser->idForName(); |
226 | 224 | } |
227 | 225 | |
228 | | - if( $uid == 0 ) { |
229 | | - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrordoesnotexist' , |
| 226 | + if ( $uid == 0 ) { |
| 227 | + $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrordoesnotexist' , |
230 | 228 | $oldusername->getText() ) . "</div>" ); |
231 | 229 | return; |
232 | 230 | } |
233 | 231 | |
234 | | - if( $newuser->idForName() != 0 ) { |
235 | | - $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorexists', |
| 232 | + if ( $newuser->idForName() != 0 ) { |
| 233 | + $wgOut->addWikiText( "<div class=\"errorbox\">" . wfMsg( 'renameusererrorexists', |
236 | 234 | $newusername->getText() ) . "</div>" ); |
237 | 235 | return; |
238 | 236 | } |
— | — | @@ -240,9 +238,9 @@ |
241 | 239 | $contribs = User::edits( $uid ); |
242 | 240 | |
243 | 241 | // Check edit count |
244 | | - if( !$wgUser->isAllowed( 'siteadmin' ) ) { |
| 242 | + if ( !$wgUser->isAllowed( 'siteadmin' ) ) { |
245 | 243 | if ( RENAMEUSER_CONTRIBLIMIT != 0 && $contribs > RENAMEUSER_CONTRIBLIMIT ) { |
246 | | - $wgOut->addWikiText( "<div class=\"errorbox\">" . |
| 244 | + $wgOut->addWikiText( "<div class=\"errorbox\">" . |
247 | 245 | wfMsg( 'renameusererrortoomany', |
248 | 246 | $oldusername->getText(), |
249 | 247 | $wgLang->formatNum( $contribs ), |
— | — | @@ -254,29 +252,29 @@ |
255 | 253 | } |
256 | 254 | |
257 | 255 | // Give other affected extensions a chance to validate or abort |
258 | | - if( !wfRunHooks( 'RenameUserAbort', array( $uid, $oldusername->getText(), $newusername->getText() ) ) ) { |
| 256 | + if ( !wfRunHooks( 'RenameUserAbort', array( $uid, $oldusername->getText(), $newusername->getText() ) ) ) { |
259 | 257 | return; |
260 | 258 | } |
261 | 259 | |
262 | 260 | // Do the heavy lifting... |
263 | 261 | $rename = new RenameuserSQL( $oldusername->getText(), $newusername->getText(), $uid ); |
264 | | - if( !$rename->rename() ) { |
| 262 | + if ( !$rename->rename() ) { |
265 | 263 | return; |
266 | 264 | } |
267 | | - |
| 265 | + |
268 | 266 | // If this user is renaming his/herself, make sure that Title::moveTo() |
269 | 267 | // doesn't make a bunch of null move edits under the old name! |
270 | | - if( $wgUser->getId() == $uid ) { |
| 268 | + if ( $wgUser->getId() == $uid ) { |
271 | 269 | $wgUser->setName( $newusername->getText() ); |
272 | 270 | } |
273 | 271 | |
274 | 272 | // Log this rename |
275 | 273 | $log = new LogPage( 'renameuser' ); |
276 | | - $log->addEntry( 'renameuser', $oldusername, wfMsgExt( 'renameuser-log', array( 'parsemag', 'content' ), |
| 274 | + $log->addEntry( 'renameuser', $oldusername, wfMsgExt( 'renameuser-log', array( 'parsemag', 'content' ), |
277 | 275 | $wgContLang->formatNum( $contribs ), $reason ), $newusername->getText() ); |
278 | 276 | |
279 | 277 | // Move any user pages |
280 | | - if( $wgRequest->getCheck( 'movepages' ) && $wgUser->isAllowed( 'move' ) ) { |
| 278 | + if ( $wgRequest->getCheck( 'movepages' ) && $wgUser->isAllowed( 'move' ) ) { |
281 | 279 | $dbr = wfGetDB( DB_SLAVE ); |
282 | 280 | $oldkey = $oldusername->getDBkey(); |
283 | 281 | $pages = $dbr->select( |
— | — | @@ -284,8 +282,8 @@ |
285 | 283 | array( 'page_namespace', 'page_title' ), |
286 | 284 | array( |
287 | 285 | 'page_namespace IN (' . NS_USER . ',' . NS_USER_TALK . ')', |
288 | | - '(page_title LIKE ' . |
289 | | - $dbr->addQuotes( $dbr->escapeLike( $oldusername->getDBkey() ) . '/%' ) . |
| 286 | + '(page_title LIKE ' . |
| 287 | + $dbr->addQuotes( $dbr->escapeLike( $oldusername->getDBkey() ) . '/%' ) . |
290 | 288 | ' OR page_title = ' . $dbr->addQuotes( $oldusername->getDBkey() ) . ')' |
291 | 289 | ), |
292 | 290 | __METHOD__ |
— | — | @@ -295,16 +293,16 @@ |
296 | 294 | $skin =& $wgUser->getSkin(); |
297 | 295 | while ( $row = $dbr->fetchObject( $pages ) ) { |
298 | 296 | $oldPage = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
299 | | - $newPage = Title::makeTitleSafe( $row->page_namespace, |
| 297 | + $newPage = Title::makeTitleSafe( $row->page_namespace, |
300 | 298 | preg_replace( '!^[^/]+!', $newusername->getDBkey(), $row->page_title ) ); |
301 | 299 | # Do not autodelete or anything, title must not exist |
302 | 300 | if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) { |
303 | 301 | $link = $skin->makeKnownLinkObj( $newPage ); |
304 | 302 | $output .= '<li class="mw-renameuser-pe">' . wfMsgHtml( 'renameuser-page-exists', $link ) . '</li>'; |
305 | 303 | } else { |
306 | | - $success = $oldPage->moveTo( $newPage, false, wfMsgForContent( 'renameuser-move-log', |
| 304 | + $success = $oldPage->moveTo( $newPage, false, wfMsgForContent( 'renameuser-move-log', |
307 | 305 | $oldusername->getText(), $newusername->getText() ) ); |
308 | | - if( $success === true ) { |
| 306 | + if ( $success === true ) { |
309 | 307 | $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' ); |
310 | 308 | $newLink = $skin->makeKnownLinkObj( $newPage ); |
311 | 309 | $output .= '<li class="mw-renameuser-pm">' . wfMsgHtml( 'renameuser-page-moved', $oldLink, $newLink ) . '</li>'; |
— | — | @@ -315,12 +313,12 @@ |
316 | 314 | } |
317 | 315 | } |
318 | 316 | } |
319 | | - if( $output ) |
| 317 | + if ( $output ) |
320 | 318 | $wgOut->addHTML( '<ul>' . $output . '</ul>' ); |
321 | 319 | } |
322 | | - |
| 320 | + |
323 | 321 | // Output success message stuff :) |
324 | | - $wgOut->addWikiText( "<div class=\"successbox\">" . wfMsg( 'renameusersuccess', $oldusername->getText(), |
| 322 | + $wgOut->addWikiText( "<div class=\"successbox\">" . wfMsg( 'renameusersuccess', $oldusername->getText(), |
325 | 323 | $newusername->getText() ) . "</div><br style=\"clear:both\" />" ); |
326 | 324 | } |
327 | 325 | |
— | — | @@ -332,7 +330,6 @@ |
333 | 331 | } |
334 | 332 | |
335 | 333 | class RenameuserSQL { |
336 | | - |
337 | 334 | /** |
338 | 335 | * The old username |
339 | 336 | * |
— | — | @@ -371,33 +368,33 @@ |
372 | 369 | * @param string $old The old username |
373 | 370 | * @param string $new The new username |
374 | 371 | */ |
375 | | - function RenameuserSQL($old, $new, $uid) { |
| 372 | + function RenameuserSQL( $old, $new, $uid ) { |
376 | 373 | $this->old = $old; |
377 | 374 | $this->new = $new; |
378 | 375 | $this->uid = $uid; |
379 | | - |
| 376 | + |
380 | 377 | $this->tables = array(); // Immediate updates |
381 | | - $this->tables['image'] = array('img_user_text','img_user'); |
382 | | - $this->tables['oldimage'] = array('oi_user_text','oi_user'); |
| 378 | + $this->tables['image'] = array( 'img_user_text', 'img_user' ); |
| 379 | + $this->tables['oldimage'] = array( 'oi_user_text', 'oi_user' ); |
383 | 380 | # FIXME: $this->tables['filearchive'] = array('fa_user_text','fa_user'); (not indexed yet) |
384 | 381 | $this->tablesJob = array(); // Slow updates |
385 | 382 | // If this user has a large number of edits, use the jobqueue |
386 | | - if( User::edits($this->uid) > RENAMEUSER_CONTRIBJOB ) { |
387 | | - $this->tablesJob['revision'] = array('rev_user_text','rev_user','rev_timestamp'); |
388 | | - $this->tablesJob['archive'] = array('ar_user_text','ar_user','ar_timestamp'); |
389 | | - $this->tablesJob['logging'] = array('log_user_text','log_user','log_timestamp'); |
| 383 | + if ( User::edits( $this->uid ) > RENAMEUSER_CONTRIBJOB ) { |
| 384 | + $this->tablesJob['revision'] = array( 'rev_user_text', 'rev_user', 'rev_timestamp' ); |
| 385 | + $this->tablesJob['archive'] = array( 'ar_user_text', 'ar_user', 'ar_timestamp' ); |
| 386 | + $this->tablesJob['logging'] = array( 'log_user_text', 'log_user', 'log_timestamp' ); |
390 | 387 | } else { |
391 | | - $this->tables['revision'] = array('rev_user_text','rev_user'); |
392 | | - $this->tables['archive'] = array('ar_user_text','ar_user'); |
393 | | - $this->tables['logging'] = array('log_user_text','log_user'); |
| 388 | + $this->tables['revision'] = array( 'rev_user_text', 'rev_user' ); |
| 389 | + $this->tables['archive'] = array( 'ar_user_text', 'ar_user' ); |
| 390 | + $this->tables['logging'] = array( 'log_user_text', 'log_user' ); |
394 | 391 | } |
395 | 392 | // Recent changes is pretty hot, deadlocks occur if done all at once |
396 | | - if( wfQueriesMustScale() ) { |
397 | | - $this->tablesJob['recentchanges'] = array('rc_user_text','rc_user','rc_timestamp'); |
| 393 | + if ( wfQueriesMustScale() ) { |
| 394 | + $this->tablesJob['recentchanges'] = array( 'rc_user_text', 'rc_user', 'rc_timestamp' ); |
398 | 395 | } else { |
399 | | - $this->tables['recentchanges'] = array('rc_user_text','rc_user'); |
| 396 | + $this->tables['recentchanges'] = array( 'rc_user_text', 'rc_user' ); |
400 | 397 | } |
401 | | - |
| 398 | + |
402 | 399 | wfRunHooks( 'RenameUserSQL', array( $this ) ); |
403 | 400 | } |
404 | 401 | |
— | — | @@ -416,11 +413,11 @@ |
417 | 414 | // this avoids users still being logged in and making new edits while |
418 | 415 | // being renamed, which leaves edits at the old name. |
419 | 416 | $dbw->update( 'user', |
420 | | - array( 'user_name' => $this->new, 'user_touched' => $dbw->timestamp() ), |
| 417 | + array( 'user_name' => $this->new, 'user_touched' => $dbw->timestamp() ), |
421 | 418 | array( 'user_name' => $this->old ), |
422 | 419 | __METHOD__ |
423 | 420 | ); |
424 | | - if( !$dbw->affectedRows() ) { |
| 421 | + if ( !$dbw->affectedRows() ) { |
425 | 422 | return false; |
426 | 423 | } |
427 | 424 | // Reset token to break login with central auth systems. |
— | — | @@ -450,8 +447,8 @@ |
451 | 448 | 'log_title' => $oldTitle->getDBkey() ), |
452 | 449 | __METHOD__ ); |
453 | 450 | // Do immediate updates! |
454 | | - foreach( $this->tables as $table => $fieldSet ) { |
455 | | - list($nameCol,$userCol) = $fieldSet; |
| 451 | + foreach ( $this->tables as $table => $fieldSet ) { |
| 452 | + list( $nameCol, $userCol ) = $fieldSet; |
456 | 453 | $dbw->update( $table, |
457 | 454 | array( $nameCol => $this->new ), |
458 | 455 | array( $nameCol => $this->old, $userCol => $this->uid ), |
— | — | @@ -465,7 +462,7 @@ |
466 | 463 | // is not really FIFO, so we might end up with a bunch of edits |
467 | 464 | // randomly mixed between the two new names. Some sort of rename |
468 | 465 | // lock might be in order... |
469 | | - foreach( $this->tablesJob as $table => $params ) { |
| 466 | + foreach ( $this->tablesJob as $table => $params ) { |
470 | 467 | $userTextC = $params[0]; // some *_user_text column |
471 | 468 | $userIDC = $params[1]; // some *_user column |
472 | 469 | $timestampC = $params[2]; // some *_timestamp column |
— | — | @@ -494,7 +491,7 @@ |
495 | 492 | $jobParams['minTimestamp'] = '0'; |
496 | 493 | $jobParams['maxTimestamp'] = '0'; |
497 | 494 | $jobParams['count'] = 0; |
498 | | - |
| 495 | + |
499 | 496 | // Insert into queue! |
500 | 497 | $jobRows = 0; |
501 | 498 | $done = false; |
— | — | @@ -504,7 +501,7 @@ |
505 | 502 | $row = $dbw->fetchObject( $res ); |
506 | 503 | if ( !$row ) { |
507 | 504 | # If there are any job rows left, add it to the queue as one job |
508 | | - if( $jobRows > 0 ) { |
| 505 | + if ( $jobRows > 0 ) { |
509 | 506 | $jobParams['count'] = $jobRows; |
510 | 507 | $jobs[] = Job::factory( 'renameUser', $oldTitle, $jobParams ); |
511 | 508 | $jobParams['minTimestamp'] = '0'; |
— | — | @@ -517,7 +514,7 @@ |
518 | 515 | } |
519 | 516 | # If we are adding the first item, since the ORDER BY is ASC, set |
520 | 517 | # the min timestamp |
521 | | - if( $jobRows == 0 ) { |
| 518 | + if ( $jobRows == 0 ) { |
522 | 519 | $jobParams['minTimestamp'] = $row->$timestampC; |
523 | 520 | } |
524 | 521 | # Keep updating the last timestamp, so it should be correct when the last item is added. |
— | — | @@ -525,7 +522,7 @@ |
526 | 523 | # Update nice counter |
527 | 524 | $jobRows++; |
528 | 525 | # Once a job has $jobSize rows, add it to the queue |
529 | | - if( $jobRows >= $jobSize ) { |
| 526 | + if ( $jobRows >= $jobSize ) { |
530 | 527 | $jobParams['count'] = $jobRows; |
531 | 528 | $jobs[] = Job::factory( 'renameUser', $oldTitle, $jobParams ); |
532 | 529 | $jobParams['minTimestamp'] = '0'; |
Index: trunk/extensions/Renameuser/Renameuser.i18n.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Internationalisation file for extension Renameuser. |
5 | 5 | * |
6 | 6 | * @addtogroup Extensions |
7 | | -*/ |
| 7 | + */ |
8 | 8 | |
9 | 9 | $messages = array(); |
10 | 10 | |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | 'renameuser-move-log' => 'Automatically moved page while renaming the user "[[User:$1|$1]]" to "[[User:$2|$2]]"', |
44 | 44 | |
45 | 45 | 'right-renameuser' => 'Rename users', |
46 | | - |
| 46 | + |
47 | 47 | 'renameuser-renamed-notice' => 'This user has been renamed. |
48 | 48 | The rename log is provided below for reference.', # Supports GENDER |
49 | 49 | ); |
— | — | @@ -3392,7 +3392,7 @@ |
3393 | 3393 | 'renameusererrorexists' => '"<nowiki>$1</nowiki>" ulanyjysy eýýäm bar.', |
3394 | 3394 | 'renameusererrorinvalid' => '"<nowiki>$1</nowiki>" ulanyjy ady nädogry.', |
3395 | 3395 | 'renameusererrortoomany' => '"<nowiki>$1</nowiki>" ulanyjysynyň $2 {{PLURAL:$2|goşandy|goşandy}} bar, $3 gowrak {{PLURAL:$3|goşandy|goşandy}} bar bolan ulanyjyny saýtyň işleýişine ýaramaz täsir eder.', |
3396 | | - 'renameuser-error-request' => 'Talaby almak bilen baglanyşykyly bir probleme ýüze çykdy. |
| 3396 | + 'renameuser-error-request' => 'Talaby almak bilen baglanyşykyly bir probleme ýüze çykdy. |
3397 | 3397 | Yza gaýdyp gaýtadan synanyşyp görüň.', |
3398 | 3398 | 'renameuser-error-same-user' => 'Ulanyja öňküsi ýaly bir ada täzeden geçirip bilmeýärsiňiz.', |
3399 | 3399 | 'renameusersuccess' => 'Ulanyjy "<nowiki>$1</nowiki>" täze ada geçirildi: "<nowiki>$2</nowiki>".', |
Index: trunk/extensions/Renameuser/Renameuser.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | /** |
5 | 5 | * A Special Page extension to rename users, runnable by users with renameuser |
6 | 6 | * righs |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | ); |
25 | 25 | |
26 | 26 | # Internationalisation file |
27 | | -$dir = dirname(__FILE__) . '/'; |
| 27 | +$dir = dirname( __FILE__ ) . '/'; |
28 | 28 | $wgExtensionMessagesFiles['Renameuser'] = $dir . 'Renameuser.i18n.php'; |
29 | 29 | $wgExtensionAliasesFiles['Renameuser'] = $dir . 'Renameuser.alias.php'; |
30 | 30 | |
— | — | @@ -39,11 +39,11 @@ |
40 | 40 | $wgLogTypes[] = 'renameuser'; |
41 | 41 | $wgLogNames['renameuser'] = 'renameuserlogpage'; |
42 | 42 | $wgLogHeaders['renameuser'] = 'renameuserlogpagetext'; |
43 | | -#$wgLogActions['renameuser/renameuser'] = 'renameuserlogentry'; |
| 43 | +# $wgLogActions['renameuser/renameuser'] = 'renameuserlogentry'; |
44 | 44 | $wgLogActionsHandlers['renameuser/renameuser'] = 'wfRenameUserLogActionText'; // deal with old breakage |
45 | 45 | |
46 | | -function wfRenameUserLogActionText( $type, $action, $title = null, $skin = null, $params = array(), $filterWikilinks=false ) { |
47 | | - if( !$title || $title->getNamespace() !== NS_USER ) { |
| 46 | +function wfRenameUserLogActionText( $type, $action, $title = null, $skin = null, $params = array(), $filterWikilinks = false ) { |
| 47 | + if ( !$title || $title->getNamespace() !== NS_USER ) { |
48 | 48 | $rv = ''; // handled in comment, the old way |
49 | 49 | } else { |
50 | 50 | $titleLink = $skin ? |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | $wgAutoloadClasses['SpecialRenameuser'] = dirname( __FILE__ ) . '/Renameuser_body.php'; |
60 | | -$wgAutoloadClasses['RenameUserJob'] = dirname(__FILE__) . '/RenameUserJob.php'; |
| 60 | +$wgAutoloadClasses['RenameUserJob'] = dirname( __FILE__ ) . '/RenameUserJob.php'; |
61 | 61 | $wgSpecialPages['Renameuser'] = 'SpecialRenameuser'; |
62 | 62 | $wgSpecialPageGroups['Renameuser'] = 'users'; |
63 | 63 | $wgJobClasses['renameUser'] = 'RenameUserJob'; |
— | — | @@ -70,23 +70,23 @@ |
71 | 71 | if ( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) { |
72 | 72 | // Get the title for the base userpage |
73 | 73 | $page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )->getPrefixedDBkey(); |
74 | | - LogEventsList::showLogExtract( $wgOut, 'renameuser', $page, '', array( 'lim' => 10, 'showIfEmpty' => false, |
| 74 | + LogEventsList::showLogExtract( $wgOut, 'renameuser', $page, '', array( 'lim' => 10, 'showIfEmpty' => false, |
75 | 75 | 'msgKey' => array( 'renameuser-renamed-notice', $title->getBaseText() ) ) ); |
76 | 76 | } |
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
80 | 80 | function wfRenameuserOnContribsLink( $id, $nt, &$tools ) { |
81 | | - global $wgUser; |
| 81 | + global $wgUser; |
82 | 82 | |
83 | | - if ( $wgUser->isAllowed( 'renameuser' ) ) { |
84 | | - $sk = $wgUser->getSkin(); |
85 | | - $tools[] = $sk->link( |
86 | | - SpecialPage::getTitleFor( 'Renameuser' ), |
87 | | - wfMsg( 'renameuser-linkoncontribs' ), |
88 | | - array( 'title' => wfMsgExt( 'renameuser-linkoncontribs-text', 'parseinline' ) ), |
89 | | - array( 'oldusername' => $nt->getText() ) |
90 | | - ); |
91 | | - } |
92 | | - return true; |
| 83 | + if ( $wgUser->isAllowed( 'renameuser' ) ) { |
| 84 | + $sk = $wgUser->getSkin(); |
| 85 | + $tools[] = $sk->link( |
| 86 | + SpecialPage::getTitleFor( 'Renameuser' ), |
| 87 | + wfMsg( 'renameuser-linkoncontribs' ), |
| 88 | + array( 'title' => wfMsgExt( 'renameuser-linkoncontribs-text', 'parseinline' ) ), |
| 89 | + array( 'oldusername' => $nt->getText() ) |
| 90 | + ); |
| 91 | + } |
| 92 | + return true; |
93 | 93 | } |