2007-01-05 18:08:29 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2010-12-04 03:20:14 +00:00
|
|
|
* Deletes all pages in the MediaWiki namespace which were last edited by
|
2007-01-05 18:08:29 +00:00
|
|
|
* "MediaWiki default".
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-08 20:47:27 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2007-01-05 18:08:29 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-08-27 19:03:15 +00:00
|
|
|
require_once( __DIR__ . '/Maintenance.php' );
|
2007-01-05 18:08:29 +00:00
|
|
|
|
2012-07-08 20:47:27 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script that deletes all pages in the MediaWiki namespace
|
|
|
|
|
* which were last edited by "MediaWiki default".
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class DeleteDefaultMessages extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->mDescription = "Deletes all pages in the MediaWiki namespace" .
|
|
|
|
|
" which were last edited by \"MediaWiki default\"";
|
|
|
|
|
}
|
2007-01-05 18:08:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2011-12-28 19:35:31 +00:00
|
|
|
global $wgUser;
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2010-09-28 18:44:25 +00:00
|
|
|
$this->output( "Checking existence of old default messages..." );
|
2009-08-02 19:35:17 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$res = $dbr->select( array( 'page', 'revision' ),
|
|
|
|
|
array( 'page_namespace', 'page_title' ),
|
|
|
|
|
array(
|
|
|
|
|
'page_namespace' => NS_MEDIAWIKI,
|
|
|
|
|
'page_latest=rev_id',
|
|
|
|
|
'rev_user_text' => 'MediaWiki default',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2013-04-18 18:48:44 +00:00
|
|
|
if ( $dbr->numRows( $res ) == 0 ) {
|
2010-09-28 18:44:25 +00:00
|
|
|
# No more messages left
|
|
|
|
|
$this->output( "done.\n" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Deletions will be made by $user temporarly added to the bot group
|
|
|
|
|
# in order to hide it in RecentChanges.
|
2011-12-28 19:35:31 +00:00
|
|
|
$user = User::newFromName( 'MediaWiki default' );
|
|
|
|
|
if ( !$user ) {
|
2011-11-20 10:55:58 +00:00
|
|
|
$this->error( "Invalid username", true );
|
|
|
|
|
}
|
2011-12-28 19:35:31 +00:00
|
|
|
$user->addGroup( 'bot' );
|
|
|
|
|
$wgUser = $user;
|
2010-09-28 18:44:25 +00:00
|
|
|
|
|
|
|
|
# Handle deletion
|
|
|
|
|
$this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
|
2009-08-02 19:35:17 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2009-08-02 20:21:12 +00:00
|
|
|
|
2009-08-17 21:15:31 +00:00
|
|
|
foreach ( $res as $row ) {
|
2011-06-17 16:39:21 +00:00
|
|
|
wfWaitForSlaves();
|
2009-08-02 19:35:17 +00:00
|
|
|
$dbw->ping();
|
|
|
|
|
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
|
2011-12-28 19:35:31 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2012-02-24 18:45:24 +00:00
|
|
|
$dbw->begin( __METHOD__ );
|
2011-12-28 19:35:31 +00:00
|
|
|
$error = ''; // Passed by ref
|
|
|
|
|
$page->doDeleteArticle( 'No longer required', false, 0, false, $error, $user );
|
2012-02-24 18:45:24 +00:00
|
|
|
$dbw->commit( __METHOD__ );
|
2007-01-05 18:08:29 +00:00
|
|
|
}
|
2010-08-16 14:23:28 +00:00
|
|
|
|
2012-03-21 23:57:16 +00:00
|
|
|
$this->output( "done!\n", 'msg' );
|
2007-01-05 18:08:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-06-29 01:19:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$maintClass = "DeleteDefaultMessages";
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|