Index: trunk/phase3/maintenance/deleteDefaultMessages.php |
— | — | @@ -32,15 +32,10 @@ |
33 | 33 | |
34 | 34 | public function execute() { |
35 | 35 | |
36 | | - $this->output( 'Deleting old default messages (this may take a long time!)...', 'msg' ); |
37 | | - |
38 | 36 | $user = 'MediaWiki default'; |
39 | 37 | $reason = 'No longer required'; |
40 | | - |
41 | | - global $wgUser; |
42 | | - $wgUser = User::newFromName( $user ); |
43 | | - $wgUser->addGroup( 'bot' ); |
44 | | - |
| 38 | + |
| 39 | + $this->output( "Checking existence of old default messages..." ); |
45 | 40 | $dbr = wfGetDB( DB_SLAVE ); |
46 | 41 | $res = $dbr->select( array( 'page', 'revision' ), |
47 | 42 | array( 'page_namespace', 'page_title' ), |
— | — | @@ -51,6 +46,20 @@ |
52 | 47 | ) |
53 | 48 | ); |
54 | 49 | |
| 50 | + if( $dbr->numRows( $res ) == 0 ) { |
| 51 | + # No more messages left |
| 52 | + $this->output( "done.\n" ); |
| 53 | + return; |
| 54 | + } |
| 55 | + |
| 56 | + # Deletions will be made by $user temporarly added to the bot group |
| 57 | + # in order to hide it in RecentChanges. |
| 58 | + global $wgUser; |
| 59 | + $wgUser = User::newFromName( $user ); |
| 60 | + $wgUser->addGroup( 'bot' ); |
| 61 | + |
| 62 | + # Handle deletion |
| 63 | + $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' ); |
55 | 64 | $dbw = wfGetDB( DB_MASTER ); |
56 | 65 | |
57 | 66 | foreach ( $res as $row ) { |