00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 require_once( 'commandLine.inc' );
00033 require_once( 'cleanupTable.inc' );
00034
00038 class WatchlistCleanup extends TableCleanup {
00039 function __construct( $dryrun = false ) {
00040 parent::__construct( 'watchlist', $dryrun );
00041 }
00042
00043 function processPage( $row ) {
00044 $current = Title::makeTitle( $row->wl_namespace, $row->wl_title );
00045 $display = $current->getPrefixedText();
00046
00047 $verified = UtfNormal::cleanUp( $display );
00048
00049 $title = Title::newFromText( $verified );
00050
00051 if( $row->wl_user == 0 || is_null( $title ) || !$title->equals( $current ) ) {
00052 $this->log( "invalid watch by {$row->wl_user} for ({$row->wl_namespace}, \"{$row->wl_title}\")" );
00053 $this->removeWatch( $row );
00054 return $this->progress( 1 );
00055 }
00056
00057 $this->progress( 0 );
00058 }
00059
00060 function removeWatch( $row ) {
00061 if( !$this->dryrun ) {
00062 $dbw = wfGetDB( DB_MASTER );
00063 $dbw->delete( 'watchlist', array(
00064 'wl_user' => $row->wl_user,
00065 'wl_namespace' => $row->wl_namespace,
00066 'wl_title' => $row->wl_title ),
00067 __METHOD__ );
00068 $this->log( '- removed' );
00069 }
00070 }
00071 }
00072
00073 $wgUser->setName( 'Conversion script' );
00074 $caps = new WatchlistCleanup( !isset( $options['fix'] ) );
00075 $caps->cleanup();
00076
00077