MediaWiki REL1_28
Go to the documentation of this file.
32require_once __DIR__ . '/';
40 protected $defaultParams = [
41 'table' => 'watchlist',
42 'index' => [ 'wl_user', 'wl_namespace', 'wl_title' ],
43 'conds' => [],
44 'callback' => 'processRow'
45 ];
47 public function __construct() {
48 parent::__construct();
49 $this->addDescription( 'Script to remove broken, unparseable titles in the Watchlist' );
50 $this->addOption( 'fix', 'Actually remove entries; without will only report.' );
51 }
53 function execute() {
54 if ( !$this->hasOption( 'fix' ) ) {
55 $this->output( "Dry run only: use --fix to enable updates\n" );
56 }
57 parent::execute();
58 }
60 protected function processRow( $row ) {
62 $current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
63 $display = $current->getPrefixedText();
64 $verified = $wgContLang->normalize( $display );
65 $title = Title::newFromText( $verified );
67 if ( $row->wl_user == 0 || is_null( $title ) || !$title->equals( $current ) ) {
68 $this->output( "invalid watch by {$row->wl_user} for "
69 . "({$row->wl_namespace}, \"{$row->wl_title}\")\n" );
70 $updated = $this->removeWatch( $row );
71 $this->progress( $updated );
73 return;
74 }
75 $this->progress( 0 );
76 }
78 private function removeWatch( $row ) {
79 if ( !$this->dryrun && $this->hasOption( 'fix' ) ) {
80 $dbw = $this->getDB( DB_MASTER );
81 $dbw->delete(
82 'watchlist', [
83 'wl_user' => $row->wl_user,
84 'wl_namespace' => $row->wl_namespace,
85 'wl_title' => $row->wl_title ],
86 __METHOD__
87 );
89 $this->output( "- removed\n" );
91 return 1;
92 } else {
93 return 0;
94 }
95 }
98$maintClass = "WatchlistCleanup";
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Generic class to cleanup a database table.
progress( $updated)
Maintenance script to remove broken, unparseable titles in the watchlist table.
Default constructor.
Do the actual work.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Definition defines.php:23