* (bug 5195) rebuildrecentchanges.php works again; Database::insertSelect now has...
[lhc/web/wiklou.git] / maintenance / updaters.inc
index bb681d6..6f33841 100644 (file)
@@ -26,6 +26,8 @@ $wgNewTables = array(
        array( 'user_newtalk',  'patch-usernewtalk2.sql' ),
        array( 'transcache',    'patch-transcache.sql' ),
        array( 'trackbacks',    'patch-trackbacks.sql' ),
+       array( 'externallinks', 'patch-externallinks.sql' ),
+       array( 'job',           'patch-job.sql' ),
 );
 
 $wgNewFields = array(
@@ -52,6 +54,7 @@ $wgNewFields = array(
        array( 'site_stats',    'ss_total_pages',   'patch-ss_total_articles.sql' ),
        array( 'interwiki',     'iw_trans',         'patch-interwiki-trans.sql' ),
        array( 'ipblocks',      'ipb_range_start',  'patch-ipb_range_start.sql' ),
+       array( 'site_stats',    'ss_images',        'patch-ss_images.sql' ),
 );
 
 function rename_table( $from, $to, $patch ) {
@@ -198,6 +201,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 {
@@ -206,6 +210,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() {
@@ -368,7 +390,7 @@ function do_schema_restructuring() {
                        UNIQUE INDEX name_title (page_namespace,page_title),
                        INDEX (page_random),
                        INDEX (page_len)
-                       ) TYPE=InnoDB", $fname );
+                       ) ENGINE=InnoDB", $fname );
                $wgDatabase->query("CREATE TABLE $revision (
                        rev_id int(8) unsigned NOT NULL auto_increment,
                        rev_page int(8) unsigned NOT NULL,
@@ -385,7 +407,7 @@ function do_schema_restructuring() {
                        INDEX page_timestamp (rev_page,rev_timestamp),
                        INDEX user_timestamp (rev_user,rev_timestamp),
                        INDEX usertext_timestamp (rev_user_text,rev_timestamp)
-                       ) TYPE=InnoDB", $fname );
+                       ) ENGINE=InnoDB", $fname );
 
                echo wfTimestamp();
                echo "......Locking tables.\n";
@@ -738,8 +760,10 @@ function do_templatelinks_update() {
        echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
 }
 
-function do_all_updates() {
-       global $wgNewTables, $wgNewFields, $wgRenamedTables;
+function do_all_updates( $doShared = false ) {
+       global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgDatabase;
+
+       $doUser = !$wgSharedDB || $doShared;
 
        # Rename tables
        foreach ( $wgRenamedTables as $tableRecord ) {
@@ -754,7 +778,9 @@ function do_all_updates() {
 
        # Add missing fields
        foreach ( $wgNewFields as $fieldRecord ) {
-               add_field( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2] );
+               if ( $fieldRecord[0] != 'user' || $doUser ) {
+                       add_field( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2] );
+               }
                flush();
        }
 
@@ -764,7 +790,9 @@ function do_all_updates() {
        do_old_links_update(); flush();
        do_image_name_unique_update(); flush();
        do_watchlist_update(); flush();
-       do_user_update(); flush();
+       if ( $doUser ) {
+               do_user_update(); flush();
+       }
 ###### do_copy_newtalk_to_watchlist(); flush();
        do_logging_encoding(); flush();
 
@@ -778,7 +806,9 @@ function do_all_updates() {
 
        do_drop_img_type(); flush();
 
-       do_user_unique_update(); flush();
+       if ( $doUser ) {
+               do_user_unique_update(); flush();
+       }
        do_user_groups_update(); flush();
 
        do_watchlist_null(); flush();