X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2Fupdaters.inc;h=5352d06578e9882cc6886762187c3bd6af2b2922;hb=23cfebd3d25fcdb0717daad5982fc9f36aa5a1b5;hp=ddf7ca782152961eb40b2dccc5cf452c4a30edd4;hpb=4efb673f444ea9f3400ff4f4b4d739bbbbf67f43;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index ddf7ca7821..5352d06578 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -38,6 +38,7 @@ $wgUpdates = array( array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ), // do_linkscc_1_3_update obsolete array( 'do_old_links_update' ), + array( 'fix_ancient_imagelinks' ), array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ), // 1.4 @@ -143,7 +144,6 @@ $wgUpdates = 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' ), // 1.14 array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), @@ -155,6 +155,13 @@ $wgUpdates = array( array( 'add_table', 'change_tag', 'patch-change_tag.sql' ), array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ), array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ), + + // 1.16 + array( 'add_table', 'user_properties', 'patch-user_properties.sql' ), + array( 'add_table', 'log_search', 'patch-log_search.sql' ), + array( 'do_log_search_population' ), + array( 'add_field', 'logging', 'log_user_text', 'patch-log_user_text.sql' ), + array( 'add_table', 'l10n_cache', 'patch-l10n_cache.sql' ), ), 'sqlite' => array( @@ -168,6 +175,13 @@ $wgUpdates = array( array( 'add_table', 'change_tag', 'patch-change_tag.sql' ), array( 'add_table', 'tag_summary', 'patch-change_tag.sql' ), array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ), + + // 1.16 + array( 'add_table', 'user_properties', 'patch-user_properties.sql' ), + array( 'add_table', 'log_search', 'patch-log_search.sql' ), + array( 'do_log_search_population' ), + array( 'add_field', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ), + array( 'add_table', 'l10n_cache', 'patch-l10n_cache.sql' ), ), ); @@ -176,7 +190,8 @@ $wgUpdates = array( # $wgDBtype should be checked to specifiy the proper file $wgExtNewTables = array(); // table, dir $wgExtNewFields = array(); // table, column, dir -$wgExtPGNewFields = array(); // table, column attributes; for PostgreSQL +$wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL +$wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL $wgExtNewIndexes = array(); // table, index, dir # Helper function: check if the given key is present in the updatelog table. @@ -257,41 +272,6 @@ function add_index( $table, $index, $patch, $fullpath=false ) { } } -function do_revision_updates() { - global $wgSoftwareRevision; - if ( $wgSoftwareRevision < 1001 ) { - update_passwords(); - } -} - -function update_passwords() { - wfDebugDieBacktrace( "This function needs to be updated or removed.\n" ); - - global $wgDatabase; - $fname = "Update script: update_passwords()"; - wfOut( "\nIt appears that you need to update the user passwords in your\n" . - "database. If you have already done this (if you've run this update\n" . - "script once before, for example), doing so again will make all your\n" . - "user accounts inaccessible, so be sure you only do this once.\n" . - "Update user passwords? (yes/no)" ); - - $resp = readconsole(); - if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } - - $sql = "SELECT user_id,user_password FROM user"; - $source = $wgDatabase->query( $sql, $fname ); - - while ( $row = $wgDatabase->fetchObject( $source ) ) { - $id = $row->user_id; - $oldpass = $row->user_password; - $newpass = md5( "{$id}-{$oldpass}" ); - - $sql = "UPDATE user SET user_password='{$newpass}' " . - "WHERE user_id={$id}"; - $wgDatabase->query( $sql, $fname ); - } -} - function do_interwiki_update() { # Check that interwiki table exists; if it doesn't source it global $wgDatabase, $IP; @@ -780,6 +760,19 @@ function do_old_links_update() { } } +function fix_ancient_imagelinks() { + global $wgDatabase; + $info = $wgDatabase->fieldInfo( 'imagelinks', 'il_from' ); + if ( $info && $info->type() === 'string' ) { + wfOut( "Fixing ancient broken imagelinks table.\n" ); + wfOut( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" ); + dbsource( archive( 'patch-fix-il_from.sql' ) ); + wfOut( "ok\n" ); + } else { + wfOut( "...il_from OK\n" ); + } +} + function do_user_unique_update() { global $wgDatabase; $duper = new UserDupes( $wgDatabase ); @@ -1016,7 +1009,7 @@ function do_filearchive_indices_update() { $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ ); if ( !$info ) { - dbsource( archive( 'patch-filearhive-user-index.sql' ) ); + dbsource( archive( 'patch-filearchive-user-index.sql' ) ); wfOut( "...filearchive indices updated\n" ); } } @@ -1241,29 +1234,6 @@ function do_populate_parent_id() { populate_rev_parent_id( $wgDatabase ); } -function update_password_format() { - if ( update_row_exists( 'password format' ) ) { - wfOut( "...password hash format already changed\n" ); - return; - } - - wfOut( "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__ ); - - wfOut( "done\n" ); -} - function sqlite_initial_indexes() { global $wgDatabase; if ( update_row_exists( 'initial_indexes' ) ) { @@ -1287,6 +1257,21 @@ function do_unique_pl_tl_il() { } } +function do_log_search_population() { + global $wgDatabase; + if( update_row_exists( 'populate log_search' ) ) { + wfOut( "...log_search table already populated.\n" ); + return; + } + require_once( 'populateLogSearch.inc' ); + wfOut( +"Populating log_search table, printing progress markers. For large\n" . +"databases, you may want to hit Ctrl-C and do this manually with\n" . +"maintenance/populateLogSearch.php.\n" ); + migrate_log_params( $wgDatabase ); + wfOut( "Done populating log_search table.\n" ); +} + /*********************************************************************** * Start PG crap * TODO: merge with above @@ -1500,8 +1485,10 @@ function do_postgres_updates() { array("redirect", "patch-redirect.sql"), array("updatelog", "patch-updatelog.sql"), array('change_tag', 'patch-change_tag.sql'), - array('tag_summary', 'patch-change_tag.sql'), - array('valid_tag', 'patch-change_tag.sql'), + array('tag_summary', 'patch-change_tag.sql'), + array('valid_tag', 'patch-change_tag.sql'), + array('user_properties', 'patch-user_properties.sql'), + array('log_search', 'patch-log_search.sql'), ); $newcols = array( @@ -1807,7 +1794,7 @@ function do_postgres_updates() { dbsource(archive('patch-ipb_address_unique.sql')); } - global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes; + global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes; # Add missing extension tables foreach ( $wgExtNewTables as $nt ) { if ($wgDatabase->tableExists($nt[0])) { @@ -1827,6 +1814,26 @@ function do_postgres_updates() { wfOut( "Adding column \"$nc[0].$nc[1]\"\n" ); $wgDatabase->query( "ALTER TABLE $nc[0] ADD $nc[1] $nc[2]" ); } + # Change altered columns + foreach ( $wgExtPGAlteredFields as $nc ) { + $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]); + if (is_null($fi)) { + wfOut( "WARNING! Column \"$nc[0].$nc[1]\" does not exist but had an alter request! Please report this.\n" ); + continue; + } + $oldtype = $fi->type(); + $newtype = strtolower( $nc[2] ); + if ($oldtype === $newtype) { + wfOut( "... column \"$nc[0].$nc[1]\" has correct type of \"$newtype\"\n" ); + continue; + } + $command = "ALTER TABLE $nc[0] ALTER $nc[1] TYPE $nc[2]"; + if ( isset( $nc[3] ) ) { + $command .= " USING $nc[3]"; + } + wfOut( "Altering column \"$nc[0].$nc[1]\" from type \"$oldtype\" to \"$newtype\"\n" ); + $wgDatabase->query( $command ); + } # Add missing extension indexes foreach ( $wgExtNewIndexes as $ni ) { if (pg_index_exists($ni[0], $ni[1])) {