<?php
/**
- * @addtogroup Maintenance
+ * @file
+ * @ingroup Maintenance
*/
- /** */
-
if ( !defined( 'MEDIAWIKI' ) ) {
echo "This file is not a valid entry point\n";
exit( 1 );
array( 'do_populate_parent_id' ),
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' ),
+ array( 'do_active_users_init' ),
+ array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' )
);
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,
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";
!index_has_field('imagelinks', 'il_to', 'il_from'))
{
dbsource( archive( 'patch-backlinkindexes.sql' ) );
+ echo( "...backlinking indices updated\n" );
}
}
if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
{
dbsource( archive( 'patch-categorylinksindex.sql' ) );
+ echo( "...categorylinks indices updated\n" );
+ }
+}
+
+function do_filearchive_indices_update() {
+ global $wgDatabase;
+ echo( "Checking filearchive indices...\n" );
+ $info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
+ if ( !$info )
+ {
+ dbsource( archive( 'patch-filearhive-user-index.sql' ) );
+ echo( "...filearchive indices updated\n" );
}
}
$row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
if( $row === false ) {
echo "data is missing! rebuilding...\n";
-
- global $IP;
- require_once "$IP/maintenance/initStats.inc";
- wfInitStats();
+ } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
+ echo "missing ss_total_pages, rebuilding...\n";
} else {
echo "ok.\n";
+ return;
}
+
+ global $IP;
+ require_once "$IP/maintenance/initStats.inc";
+ wfInitStats();
+}
+
+function do_active_users_init() {
+ global $wgDatabase;
+ $activeUsers = $wgDatabase->selectField( 'site_stats', 'ss_active_users', false, __METHOD__ );
+ if( $activeUsers == -1 ) {
+ $activeUsers = $wgDatabase->selectField( 'recentchanges',
+ 'COUNT( DISTINCT rc_user_text )',
+ array( 'rc_user != 0', 'rc_bot' => 0, "rc_log_type != 'newusers'" ), __METHOD__
+ );
+ $wgDatabase->update( 'site_stats',
+ array( 'ss_active_users' => intval($activeUsers) ),
+ array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 )
+ );
+ }
+ echo( "...ss_active_users user count set...\n" );
}
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();
echo "...rev_parent_id column already populated.\n";
return;
}
- require_once( 'populateParentId.php' );
+ require_once( 'populateParentId.inc' );
+
+ global $wgDatabase;
+ 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
array("archive", "ar_page_id", "INTEGER"),
array("archive", "ar_parent_id", "INTEGER"),
array("image", "img_sha1", "TEXT NOT NULL DEFAULT ''"),
- array("ipblocks", "ipb_anon_only", "CHAR NOT NULL DEFAULT '0'"),
+ array("ipblocks", "ipb_anon_only", "SMALLINT NOT NULL DEFAULT 0"),
array("ipblocks", "ipb_by_text", "TEXT NOT NULL DEFAULT ''"),
- array("ipblocks", "ipb_block_email", "CHAR NOT NULL DEFAULT '0'"),
- array("ipblocks", "ipb_create_account", "CHAR NOT NULL DEFAULT '1'"),
+ array("ipblocks", "ipb_block_email", "SMALLINT NOT NULL DEFAULT 0"),
+ array("ipblocks", "ipb_create_account", "SMALLINT NOT NULL DEFAULT 1"),
array("ipblocks", "ipb_deleted", "SMALLINT NOT NULL DEFAULT 0"),
- array("ipblocks", "ipb_enable_autoblock", "CHAR NOT NULL DEFAULT '1'"),
+ array("ipblocks", "ipb_enable_autoblock", "SMALLINT NOT NULL DEFAULT 1"),
+ array("ipblocks", "ipb_allow_usertalk", "SMALLINT NOT NULL DEFAULT 0"),
array("filearchive", "fa_deleted", "SMALLINT NOT NULL DEFAULT 0"),
array("logging", "log_deleted", "SMALLINT NOT NULL DEFAULT 0"),
array("logging", "log_id", "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('log_log_id_seq')"),
array("revision", "rev_len", "INTEGER"),
array("revision", "rev_deleted", "SMALLINT NOT NULL DEFAULT 0"),
array("user_newtalk", "user_last_timestamp", "TIMESTAMPTZ"),
+ array("site_stats", "ss_active_users", "INTEGER DEFAULT '-1'"),
+ array("revision", "rev_parent_id", "INTEGER DEFAULT NULL"),
);
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')"),
array("mwuser", "user_email_token","text", ""),
array("objectcache", "keyname", "text", ""),
array("oldimage", "oi_height", "integer", ""),
+ array("oldimage", "oi_metadata", "bytea", "decode(img_metadata,'escape')"),
array("oldimage", "oi_size", "integer", ""),
array("oldimage", "oi_width", "integer", ""),
array("page", "page_is_redirect","smallint", "page_is_redirect::smallint DEFAULT 0"),
array("recentchanges","rc_new", "smallint", "rc_new::smallint DEFAULT 0"),
array("recentchanges","rc_type", "smallint", "rc_type::smallint DEFAULT 0"),
array("recentchanges","rc_patrolled", "smallint", "rc_patrolled::smallint DEFAULT 0"),
+ array("revision", "rev_deleted", "smallint", "rev_deleted::smallint DEFAULT 0"),
array("revision", "rev_minor_edit", "smallint", "rev_minor_edit::smallint DEFAULT 0"),
array("templatelinks","tl_namespace", "smallint", "tl_namespace::smallint"),
array("user_newtalk", "user_ip", "text", "host(user_ip)"),
);
$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("templatelinks", "templatelinks_from", "(tl_from)"),
+ array("watchlist", "wl_user", "(wl_user)"),
);
$newrules = array(
$wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)");
}
else
- echo "... index \"pagelink_unique_index\" aready exists\n";
+ echo "... index \"pagelink_unique_index\" already exists\n";
if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') {
echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n";
dbsource(archive('patch-revision_rev_user_fkey.sql'));
}
+ # Fix ipb_address index
+ if (pg_index_exists('ipblocks', 'ipb_address' )) {
+ echo "Removing deprecated index 'ipb_address'...\n";
+ $wgDatabase->query('DROP INDEX ipb_address');
+ }
+ if (pg_index_exists('ipblocks', 'ipb_address_unique' )) {
+ echo "... have ipb_address_unique\n";
+ }
+ else {
+ echo "Adding ipb_address_unique index\n";
+ dbsource(archive('patch-ipb_address_unique.sql'));
+ }
+
global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes;
# Add missing extension tables
foreach ( $wgExtNewTables as $nt ) {
# This is create or replace, so harmless to call if not needed
dbsource(archive('patch-ts2pagetitle.sql'));
- ## If the server is 8.3 or higher, rewrite teh tsearch2 triggers
+ ## If the server is 8.3 or higher, rewrite the tsearch2 triggers
## in case they have the old 'default' versions
if ( $numver >= 8.3 )
dbsource(archive('patch-tsearch2funcs.sql'));
+ ## Put a new row in the mediawiki_version table
+ $wgDatabase->insert( 'mediawiki_version',
+ array(
+ 'type' => 'Update',
+ 'ctype' => 'U',
+ 'mw_version' => $wgVersion,
+ 'pg_version' => $version,
+ 'sql_version' => '$LastChangedRevision$',
+ 'sql_date' => '$LastChangedDate$',
+ ) );
return;
}