Cleanup r55984: rename new $wgDisableTooltipsAndAccesskeys to $wgEnableTooltipsAndAcc...
[lhc/web/wiklou.git] / maintenance / cleanupWatchlist.php
1 <?php
2 /*
3 * Script to remove broken, unparseable titles in the Watchlist.
4 *
5 * Usage: php cleanupWatchlist.php [--fix]
6 * Options:
7 * --fix Actually remove entries; without will only report.
8 *
9 * Copyright (C) 2005,2006 Brion Vibber <brion@pobox.com>
10 * http://www.mediawiki.org/
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 * http://www.gnu.org/copyleft/gpl.html
26 *
27 * @author Brion Vibber <brion at pobox.com>
28 * @ingroup Maintenance
29 */
30
31 require_once( dirname(__FILE__) . '/cleanupTable.inc' );
32
33 class WatchlistCleanup extends TableCleanup {
34 protected $targetTable = 'watchlist';
35 public function __construct() {
36 parent::__construct();
37 $this->mDescription = "Script to remove broken, unparseable titles in the Watchlist";
38 }
39
40 protected function processPage( $row ) {
41 $current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
42 $display = $current->getPrefixedText();
43 $verified = UtfNormal::cleanUp( $display );
44 $title = Title::newFromText( $verified );
45
46 if( $row->wl_user == 0 || is_null( $title ) || !$title->equals( $current ) ) {
47 $this->output( "invalid watch by {$row->wl_user} for ({$row->wl_namespace}, \"{$row->wl_title}\")\n" );
48 $this->removeWatch( $row );
49 return $this->progress( 1 );
50 }
51 $this->progress( 0 );
52 }
53
54 private function removeWatch( $row ) {
55 if( !$this->dryrun ) {
56 $dbw = wfGetDB( DB_MASTER );
57 $dbw->delete( 'watchlist', array(
58 'wl_user' => $row->wl_user,
59 'wl_namespace' => $row->wl_namespace,
60 'wl_title' => $row->wl_title ),
61 __METHOD__ );
62 $this->output( "- removed\n" );
63 }
64 }
65 }
66
67 $maintClass = "WatchlistCleanup";
68 require_once( DO_MAINTENANCE );