watchlist row duplication
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 22 Feb 2006 00:45:27 +0000 (00:45 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 22 Feb 2006 00:45:27 +0000 (00:45 +0000)
maintenance/updaters.inc

index d53b429..ab08e27 100644 (file)
@@ -199,6 +199,7 @@ function do_logging_timestamp_index() {
 
 function do_watchlist_update() {
        global $wgDatabase;
+       $fname = 'do_watchlist_update';
        if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) {
                echo "The watchlist table is already set up for email notification.\n";
        } else {
@@ -207,6 +208,24 @@ function do_watchlist_update() {
                dbsource( "maintenance/archives/patch-email-notification.sql", $wgDatabase );
                echo "ok\n";
        }
+       # Check if we need to add talk page rows to the watchlist
+       $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname );
+       $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname );
+       if ( $talk != $nontalk ) {
+               echo "Adding missing watchlist talk page rows... ";
+               flush();
+
+               $wgDatabase->insertSelect( 'watchlist', 'watchlist', 
+                       array(
+                               'wl_user' => 'wl_user',
+                               'wl_namespace' => 'wl_namespace | 1',
+                               'wl_title' => 'wl_title',
+                               'wl_notificationtimestamp' => 'wl_notificationtimestamp'
+                       ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' );
+               echo "ok\n";
+       } else {
+               echo "...watchlist talk page rows already present\n";
+       }
 }
 
 function do_copy_newtalk_to_watchlist() {