Changing name of Nauruan from “Ekakairũ Naoero” to “Dorerin Naoero”; this was pointed...
[lhc/web/wiklou.git] / maintenance / updaters.inc
index 32b29d5..19687b2 100644 (file)
@@ -1,10 +1,9 @@
 <?php
 /**
- * @addtogroup Maintenance
+ * @file
+ * @ingroup Maintenance
  */
 
- /** */
-
 if ( !defined( 'MEDIAWIKI' ) ) {
        echo "This file is not a valid entry point\n";
        exit( 1 );
@@ -143,6 +142,7 @@ $wgMysqlUpdates = array(
        array( 'check_bin', 'protected_titles', 'pt_title',      'patch-pt_title-encoding.sql', ),
        array( 'maybe_do_profiling_memory_update' ),
        array( 'do_filearchive_indices_update' ),
+       array( 'update_password_format' ),
 );
 
 
@@ -555,7 +555,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,
@@ -573,7 +573,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( TS_DB );
                echo "......Locking tables.\n";
@@ -1034,11 +1034,11 @@ function purge_cache() {
 }
 
 function do_all_updates( $shared = false, $purge = true ) {
-       global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgDatabase, $wgDBtype, $IP;
+       global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype, $IP;
 
        wfRunHooks('LoadExtensionSchemaUpdates');
 
-       $doUser = !$wgSharedDB || $shared;
+       $doUser = $shared ? $wgSharedDB && in_array('user', $wgSharedTables) : !$wgSharedDB || !in_array('user', $wgSharedTables);
 
        if ($wgDBtype === 'postgres') {
                do_postgres_updates();
@@ -1196,6 +1196,29 @@ function do_populate_parent_id() {
        populate_rev_parent_id( $wgDatabase );
 }
 
+function update_password_format() {
+       if ( update_row_exists( 'password format' ) ) {
+               echo "...password hash format already changed\n";
+               return;
+       }
+
+       echo "Updating password hash format...";
+
+       global $wgDatabase, $wgPasswordSalt;
+       $user = $wgDatabase->tableName( 'user' );
+       if ( $wgPasswordSalt ) {
+               $sql = "UPDATE $user SET user_password=CONCAT(':B:', user_id, ':', user_password) " .
+                       "WHERE user_password NOT LIKE ':%'";
+       } else {
+               $sql = "UPDATE $user SET user_password=CONCAT(':A:', user_password) " .
+                       "WHERE user_password NOT LIKE ':%'";
+       }
+       $wgDatabase->query( $sql, __METHOD__ );
+       $wgDatabase->insert( 'updatelog', array( 'ul_key' => 'password format' ), __METHOD__ );
+
+       echo "done\n";
+}
+
 function
 pg_describe_table($table)
 {
@@ -1461,10 +1484,10 @@ function do_postgres_updates() {
                array("interwiki",    "iw_local",        "smallint", "iw_local::smallint DEFAULT 0"),
                array("interwiki",    "iw_trans",        "smallint", "iw_trans::smallint DEFAULT 0"),
                array("ipblocks",     "ipb_auto",        "smallint", "ipb_auto::smallint DEFAULT 0"),
-               array("ipblocks",     "ipb_anon_only",   "smallint", "ipb_anon_only::smallint DEFAULT 0"),
-               array("ipblocks",     "ipb_create_account", "smallint", "ipb_create_account::smallint DEFAULT 1"),
-               array("ipblocks",     "ipb_enable_autoblock", "smallint", "ipb_enable_autoblock::smallint DEFAULT 1"),
-               array("ipblocks",     "ipb_block_email", "smallint", "ipb_block_email::smallint DEFAULT 0"),
+               array("ipblocks",     "ipb_anon_only",   "smallint", "CASE WHEN ipb_anon_only=' ' THEN 0 ELSE ipb_anon_only::smallint END DEFAULT 0"),
+               array("ipblocks",     "ipb_create_account", "smallint", "CASE WHEN ipb_create_account=' ' THEN 0 ELSE ipb_create_account::smallint END DEFAULT 1"),
+               array("ipblocks",     "ipb_enable_autoblock", "smallint", "CASE WHEN ipb_enable_autoblock=' ' THEN 0 ELSE ipb_enable_autoblock::smallint END DEFAULT 1"),
+               array("ipblocks",     "ipb_block_email", "smallint", "CASE WHEN ipb_block_email=' ' THEN 0 ELSE ipb_block_email::smallint END DEFAULT 0"),
                array("ipblocks",     "ipb_address",     "text",     "ipb_address::text"),
                array("ipblocks",     "ipb_deleted",     "smallint", "ipb_deleted::smallint"),
                array("math",         "math_inputhash",  "bytea",    "decode(math_inputhash,'escape')"),
@@ -1492,10 +1515,12 @@ function do_postgres_updates() {
        );
 
        $newindexes = array(
-               array("archive",       "archive_user_text", "(ar_user_text)"),
-               array("image",         "img_sha1",          "(img_sha1)"),
-               array("oldimage",      "oi_sha1",           "(oi_sha1)"),
-               array("revision",      "rev_text_id_idx",   "(rev_text_id)"),
+               array("archive",       "archive_user_text",  "(ar_user_text)"),
+               array("image",         "img_sha1",           "(img_sha1)"),
+               array("oldimage",      "oi_sha1",            "(oi_sha1)"),
+               array("revision",      "rev_text_id_idx",    "(rev_text_id)"),
+               array("recentchanges", "rc_timestamp_nobot", "(rc_timestamp) WHERE rc_bot = 0"),
+               array("watchlist",     "wl_user",            "(wl_user)"),
        );
 
        $newrules = array(
@@ -1691,3 +1716,4 @@ function do_postgres_updates() {
 
        return;
 }
+