MediaWiki  1.23.2
deleteDefaultMessages.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Maintenance.php';
26 
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() {
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  return;
58  }
59 
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;
68 
69  # Handle deletion
70  $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
71  $dbw = wfGetDB( DB_MASTER );
72 
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  }
83 
84  $this->output( "done!\n", 'msg' );
85  }
86 }
87 
88 $maintClass = "DeleteDefaultMessages";
89 require_once RUN_MAINTENANCE_IF_MAIN;
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
$wgUser
$wgUser
Definition: Setup.php:552
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
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
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
DeleteDefaultMessages
Maintenance script that deletes all pages in the MediaWiki namespace which were last edited by "Media...
Definition: deleteDefaultMessages.php:33
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:388
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$dbr
$dbr
Definition: testCompression.php:48
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfWaitForSlaves
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
Definition: GlobalFunctions.php:3795
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$user
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
DeleteDefaultMessages\execute
execute()
Do the actual work.
Definition: deleteDefaultMessages.php:40
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
$maintClass
$maintClass
Definition: deleteDefaultMessages.php:88
as
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
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
$error
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:2573
$res
$res
Definition: database.txt:21
DeleteDefaultMessages\__construct
__construct()
Default constructor.
Definition: deleteDefaultMessages.php:34