Run ulimit4.sh using /bin/bash to avoid noexec
[lhc/web/wiklou.git] / maintenance / deleteDefaultMessages.php
1 <?php
2 /**
3 * Deletes all pages in the MediaWiki namespace which were last edited by
4 * "MediaWiki default".
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @ingroup Maintenance
22 */
23
24 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
25
26 class DeleteDefaultMessages extends Maintenance {
27 public function __construct() {
28 parent::__construct();
29 $this->mDescription = "Deletes all pages in the MediaWiki namespace" .
30 " which were last edited by \"MediaWiki default\"";
31 }
32
33 public function execute() {
34
35 $this->output( 'Deleting old default messages (this may take a long time!)...', 'msg' );
36
37 $user = 'MediaWiki default';
38 $reason = 'No longer required';
39
40 global $wgUser;
41 $wgUser = User::newFromName( $user );
42 $wgUser->addGroup( 'bot' );
43
44 $dbr = wfGetDB( DB_SLAVE );
45 $res = $dbr->select( array( 'page', 'revision' ),
46 array( 'page_namespace', 'page_title' ),
47 array(
48 'page_namespace' => NS_MEDIAWIKI,
49 'page_latest=rev_id',
50 'rev_user_text' => 'MediaWiki default',
51 )
52 );
53
54 $dbw = wfGetDB( DB_MASTER );
55
56 foreach ( $res as $row ) {
57 if ( function_exists( 'wfWaitForSlaves' ) ) {
58 wfWaitForSlaves( 5 );
59 }
60 $dbw->ping();
61 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
62 $article = new Article( $title );
63 $dbw->begin();
64 $article->doDeleteArticle( $reason );
65 $dbw->commit();
66 }
67
68 $this->output( 'done!', 'msg' );
69 }
70 }
71
72 $maintClass = "DeleteDefaultMessages";
73 require_once( DO_MAINTENANCE );