[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
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 * @file 22 * @ingroup Maintenance 23 */ 24 25 require_once __DIR__ . '/Maintenance.php'; 26 27 /** 28 * Maintenance script that deletes all pages in the MediaWiki namespace 29 * which were last edited by "MediaWiki default". 30 * 31 * @ingroup Maintenance 32 */ 33 class DeleteDefaultMessages extends Maintenance { 34 public function __construct() { 35 parent::__construct(); 36 $this->mDescription = "Deletes all pages in the MediaWiki namespace" . 37 " which were last edited by \"MediaWiki default\""; 38 } 39 40 public function execute() { 41 global $wgUser; 42 43 $this->output( "Checking existence of old default messages..." ); 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 if ( $dbr->numRows( $res ) == 0 ) { 55 # No more messages left 56 $this->output( "done.\n" ); 57 58 return; 59 } 60 61 # Deletions will be made by $user temporarly added to the bot group 62 # in order to hide it in RecentChanges. 63 $user = User::newFromName( 'MediaWiki default' ); 64 if ( !$user ) { 65 $this->error( "Invalid username", true ); 66 } 67 $user->addGroup( 'bot' ); 68 $wgUser = $user; 69 70 # Handle deletion 71 $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' ); 72 $dbw = wfGetDB( DB_MASTER ); 73 74 foreach ( $res as $row ) { 75 wfWaitForSlaves(); 76 $dbw->ping(); 77 $title = Title::makeTitle( $row->page_namespace, $row->page_title ); 78 $page = WikiPage::factory( $title ); 79 $dbw->begin( __METHOD__ ); 80 $error = ''; // Passed by ref 81 $page->doDeleteArticle( 'No longer required', false, 0, false, $error, $user ); 82 $dbw->commit( __METHOD__ ); 83 } 84 85 $this->output( "done!\n", 'msg' ); 86 } 87 } 88 89 $maintClass = "DeleteDefaultMessages"; 90 require_once RUN_MAINTENANCE_IF_MAIN;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |