Index: trunk/extensions/ConfirmAccount/backend/ConfirmAccount.class.php |
— | — | @@ -4,40 +4,45 @@ |
5 | 5 | * Move old stale requests to rejected list. Delete old rejected requests. |
6 | 6 | */ |
7 | 7 | public static function runAutoMaintenance() { |
8 | | - global $wgRejectedAccountMaxAge, $wgConfirmAccountFSRepos; |
| 8 | + global $wgRejectedAccountMaxAge, $wgConfirmAccountRejectAge, $wgConfirmAccountFSRepos; |
9 | 9 | |
10 | 10 | $dbw = wfGetDB( DB_MASTER ); |
11 | | - # Select all items older than time $cutoff |
12 | | - $cutoff = $dbw->timestamp( time() - $wgRejectedAccountMaxAge ); |
13 | | - $accountrequests = $dbw->tableName( 'account_requests' ); |
14 | | - $sql = "SELECT acr_storage_key,acr_id FROM $accountrequests WHERE acr_rejected < '{$cutoff}'"; |
15 | | - $res = $dbw->query( $sql ); |
| 11 | + $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
16 | 12 | |
17 | | - $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
| 13 | + # Select all items older than time $encCutoff |
| 14 | + $encCutoff = $dbw->addQuotes( $dbw->timestamp( time() - $wgRejectedAccountMaxAge ) ); |
| 15 | + $res = $dbw->select( 'account_requests', |
| 16 | + array( 'acr_id', 'acr_storage_key' ), |
| 17 | + array( "acr_rejected < {$encCutoff}" ), |
| 18 | + __METHOD__ |
| 19 | + ); |
| 20 | + |
18 | 21 | # Clear out any associated attachments and delete those rows |
19 | | - foreach( $res as $row ) { |
| 22 | + foreach ( $res as $row ) { |
20 | 23 | $key = $row->acr_storage_key; |
21 | | - if( $key ) { |
| 24 | + if ( $key ) { |
22 | 25 | $path = $repo->getZonePath( 'public' ).'/'. |
23 | 26 | $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
24 | | - if( $path && file_exists($path) ) { |
| 27 | + if ( $path && file_exists($path) ) { |
25 | 28 | unlink($path); |
26 | 29 | } |
27 | 30 | } |
28 | | - $dbw->query( "DELETE FROM $accountrequests WHERE acr_id = {$row->acr_id}" ); |
| 31 | + $dbw->delete( 'account_requests', array( 'acr_id' => $row->acr_id ), __METHOD__ ); |
29 | 32 | } |
30 | 33 | |
31 | | - # Select all items older than time $cutoff |
32 | | - global $wgConfirmAccountRejectAge; |
33 | | - $cutoff = $dbw->timestamp( time() - $wgConfirmAccountRejectAge ); |
| 34 | + # Select all items older than time $encCutoff |
| 35 | + $encCutoff = $dbw->addQuotes( $dbw->timestamp( time() - $wgConfirmAccountRejectAge ) ); |
34 | 36 | # Old stale accounts will count as rejected. If the request was held, give it more time. |
35 | 37 | $dbw->update( 'account_requests', |
36 | 38 | array( 'acr_rejected' => $dbw->timestamp(), |
37 | 39 | 'acr_user' => 0, // dummy |
38 | 40 | 'acr_comment' => wfMsgForContent('confirmaccount-autorej'), |
39 | 41 | 'acr_deleted' => 1 ), |
40 | | - array( "acr_rejected IS NULL", "acr_registration < '{$cutoff}'", "acr_held < '{$cutoff}'" ), |
41 | | - __METHOD__ ); |
| 42 | + array( "acr_rejected IS NULL", |
| 43 | + "acr_registration < {$encCutoff}", |
| 44 | + "acr_held < {$encCutoff} OR acr_held IS NULL" ), |
| 45 | + __METHOD__ |
| 46 | + ); |
42 | 47 | |
43 | 48 | # Clear cache for notice of how many account requests there are |
44 | 49 | self::clearAccountRequestCountCache(); |
— | — | @@ -240,10 +245,12 @@ |
241 | 246 | } |
242 | 247 | |
243 | 248 | /** |
244 | | - * Get the category to add to this users page for working in |
| 249 | + * Get the text to add to this users page for describing editing topics |
| 250 | + * for each "area" a user can be in, as defined in MediaWiki:requestaccount-areas. |
| 251 | + * |
245 | 252 | * @return Array Associative mapping of the format: |
246 | 253 | * (name => ('project' => x, 'userText' => y, 'grpUserText' => (request type => z))) |
247 | | - * Any of the ultimative values can be empty string |
| 254 | + * Any of the ultimate values can be the empty string |
248 | 255 | */ |
249 | 256 | public static function getUserAreaConfig() { |
250 | 257 | static $res; // process cache |
— | — | @@ -271,9 +278,9 @@ |
272 | 279 | } |
273 | 280 | |
274 | 281 | $res[$name]['grpUserText'] = array(); // userpage text for certain request types |
275 | | - $categories = array_slice( $set, 3 ); // keys start from 0 now |
| 282 | + $categories = array_slice( $set, 3 ); // keys start from 0 now in $categories |
276 | 283 | foreach ( $categories as $i => $cat ) { |
277 | | - $res[$name]['grpUserText'][$i] = trim( $cat ); |
| 284 | + $res[$name]['grpUserText'][$i] = trim( $cat ); // category for group $i |
278 | 285 | } |
279 | 286 | } |
280 | 287 | } |