remove inverse_timestamp wherever it is found and disable wfInvertTimestamp()
[lhc/web/wiklou.git] / maintenance / updaters.inc
index 58eb0cc..d2d326c 100644 (file)
@@ -248,6 +248,26 @@ function do_group_update() {
        }
 }
 
+/**
+ * 1.4 betas were missing the 'binary' marker from logging.log_title,
+ * which causes a collation mismatch error on joins in MySQL 4.1.
+ */
+function do_logging_encoding() {
+       global $wgDatabase;
+       $logging = $wgDatabase->tableName( 'logging' );
+       $res = $wgDatabase->query( "SELECT log_title FROM $logging LIMIT 0" );
+       $flags = explode( ' ', mysql_field_flags( $res, 0 ) );
+       $wgDatabase->freeResult( $res );
+       
+       if( in_array( 'binary', $flags ) ) {
+               echo "Logging table has correct title encoding.\n";
+       } else {
+               echo "Fixing title encoding on logging table... ";
+               dbsource( 'maintenance/archives/patch-logging-title.sql', $wgDatabase );
+               echo "ok\n";
+       }
+}
+
 function do_schema_restructuring() {
        global $wgDatabase;
        $fname="do_schema_restructuring";
@@ -339,14 +359,13 @@ function do_schema_restructuring() {
                        rev_user_text varchar(255) binary NOT NULL default '',
                        rev_timestamp char(14) binary NOT NULL default '',
                        rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
-                       inverse_timestamp char(14) binary NOT NULL default '',
   
                        PRIMARY KEY rev_page_id (rev_page, rev_id),
                        UNIQUE INDEX rev_id (rev_id),
                        INDEX rev_timestamp (rev_timestamp),
-                       INDEX page_timestamp (rev_page,inverse_timestamp),
-                       INDEX user_timestamp (rev_user,inverse_timestamp),
-                       INDEX usertext_timestamp (rev_user_text,inverse_timestamp)
+                       INDEX page_timestamp (rev_page,rev_timestamp),
+                       INDEX user_timestamp (rev_user,rev_timestamp),
+                       INDEX usertext_timestamp (rev_user_text,rev_timestamp)
                        )", $fname );
 
                echo "......Locking tables.\n";
@@ -357,16 +376,15 @@ function do_schema_restructuring() {
 
                echo "......Moving text from cur.\n";
                $wgDatabase->query( "INSERT INTO $old (old_namespace, old_title, old_text, old_comment, old_user, old_user_text,
-                               old_timestamp, old_minor_edit, old_flags, inverse_timestamp)
-                       SELECT cur_namespace, cur_title, cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit,
-                               '', inverse_timestamp
+                               old_timestamp, old_minor_edit, old_flags, rev_timestamp)
+                       SELECT cur_namespace, cur_title, cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit,''
                        FROM $cur", $fname );
 
                echo "......Setting up revision table.\n";
                $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp,
-                               inverse_timestamp, rev_minor_edit)
+                               rev_minor_edit)
                        SELECT old_id, cur_id, old_comment, old_user, old_user_text,
-                               old_timestamp, $old.inverse_timestamp, old_minor_edit
+                               old_timestamp, old_minor_edit
                        FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname );
 
                echo "......Setting up page table.\n";
@@ -413,7 +431,8 @@ function do_all_updates() {
        do_watchlist_update(); flush();
        do_user_update(); flush();
        do_copy_newtalk_to_watchlist(); flush();
-
+       do_logging_encoding(); flush();
+       
        do_schema_restructuring(); flush();
 
        if ( isTemplateInitialised() ) {