22require_once __DIR__ .
'/TableCleanup.php';
33 'table' =>
'watchlist',
34 'index' => [
'wl_id' ],
36 'callback' =>
'processRow'
40 parent::__construct();
41 $this->
addDescription(
'Script to remove broken, unparseable titles in the Watchlist' );
42 $this->
addOption(
'fix',
'Actually remove entries; without will only report.' );
47 $this->
output(
"Dry run only: use --fix to enable updates\n" );
53 $current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
54 $display = $current->getPrefixedText();
56 $title = Title::newFromText( $verified );
58 if ( $row->wl_user == 0 || $title ===
null || !$title->equals( $current ) ) {
59 $this->
output(
"invalid watch by {$row->wl_user} for "
60 .
"({$row->wl_namespace}, \"{$row->wl_title}\")\n" );
61 $updated = $this->removeWatch( $row );
69 private function removeWatch( \stdClass $row ): int {
70 if ( !$this->dryrun && $this->
hasOption(
'fix' ) ) {
72 $dbw->newDeleteQueryBuilder()
73 ->deleteFrom(
'watchlist' )
74 ->where( [
'wl_id' => $row->wl_id ] )
75 ->caller( __METHOD__ )
77 if ( $this->
getConfig()->
get( MainConfigNames::WatchlistExpiry ) ) {
78 $dbw->newDeleteQueryBuilder()
79 ->deleteFrom(
'watchlist_expiry' )
80 ->where( [
'we_item' => $row->wl_id ] )
81 ->caller( __METHOD__ )
85 $this->
output(
"- removed\n" );
96require_once RUN_MAINTENANCE_IF_MAIN;
if(!defined('MW_SETUP_CALLBACK'))
Maintenance script to remove broken, unparseable titles in the watchlist table.
execute()
Do the actual work.
processRow(\stdClass $row)
__construct()
Default constructor.
A class containing constants representing the names of configuration variables.
output( $out, $channel=null)
Throw some output to the user.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getServiceContainer()
Returns the main service container.
getPrimaryDB(string|false $virtualDomain=false)
addDescription( $text)
Set the description text.
Generic class to cleanup a database table.