MediaWiki  1.23.12
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Maintenance.php';
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  }
40  public function execute() {
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  );
54  if ( $dbr->numRows( $res ) == 0 ) {
55  # No more messages left
56  $this->output( "done.\n" );
57  return;
58  }
60  # Deletions will be made by $user temporarly added to the bot group
61  # in order to hide it in RecentChanges.
62  $user = User::newFromName( 'MediaWiki default' );
63  if ( !$user ) {
64  $this->error( "Invalid username", true );
65  }
66  $user->addGroup( 'bot' );
67  $wgUser = $user;
69  # Handle deletion
70  $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
71  $dbw = wfGetDB( DB_MASTER );
73  foreach ( $res as $row ) {
75  $dbw->ping();
76  $title = Title::makeTitle( $row->page_namespace, $row->page_title );
77  $page = WikiPage::factory( $title );
78  $dbw->begin( __METHOD__ );
79  $error = ''; // Passed by ref
80  $page->doDeleteArticle( 'No longer required', false, 0, false, $error, $user );
81  $dbw->commit( __METHOD__ );
82  }
84  $this->output( "done!\n", 'msg' );
85  }
86 }
88 $maintClass = "DeleteDefaultMessages";
89 require_once RUN_MAINTENANCE_IF_MAIN;
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
Definition: Setup.php:572
Definition: Defines.php:56
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
Maintenance script that deletes all pages in the MediaWiki namespace which were last edited by "Media...
Definition: deleteDefaultMessages.php:33
Definition: maintenance.txt:50
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:389
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
Definition: testCompression.php:48
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
Definition: GlobalFunctions.php:3851
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
Do the actual work.
Definition: deleteDefaultMessages.php:40
const DB_SLAVE
Definition: Defines.php:55
Definition: deleteDefaultMessages.php:88
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Definition: Defines.php:87
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
Definition: hooks.txt:2578
Definition: database.txt:21
Default constructor.
Definition: deleteDefaultMessages.php:34