summaryrefslogtreecommitdiff
path: root/maintenance/updaters.inc
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/updaters.inc')
-rw-r--r--maintenance/updaters.inc74
1 files changed, 60 insertions, 14 deletions
diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc
index 13cdc4c8..e671efe5 100644
--- a/maintenance/updaters.inc
+++ b/maintenance/updaters.inc
@@ -143,6 +143,11 @@ $wgMysqlUpdates = array(
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' )
);
@@ -1015,12 +1020,32 @@ function do_stats_init() {
$row = $wgDatabase->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
if( $row === false ) {
wfOut( "data is missing! rebuilding...\n" );
- global $IP;
- require_once "$IP/maintenance/initStats.inc";
- wfInitStats();
+ } elseif ( isset( $row->site_stats ) && $row->ss_total_pages == -1 ) {
+ wfOut( "missing ss_total_pages, rebuilding...\n" );
} else {
wfOut( "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 )
+ );
}
+ wfOut( "...ss_active_users user count set...\n" );
}
function purge_cache() {
@@ -1431,12 +1456,13 @@ function do_postgres_updates() {
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')"),
@@ -1461,6 +1487,8 @@ function do_postgres_updates() {
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"),
);
@@ -1494,6 +1522,7 @@ function do_postgres_updates() {
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"),
@@ -1513,10 +1542,13 @@ 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("templatelinks", "templatelinks_from", "(tl_from)"),
+ array("watchlist", "wl_user", "(wl_user)"),
);
$newrules = array(
@@ -1672,9 +1704,14 @@ function do_postgres_updates() {
}
# Fix ipb_address index
+ if (pg_index_exists('ipblocks', 'ipb_address' )) {
+ wfOut( "Removing deprecated index 'ipb_address'...\n" );
+ $wgDatabase->query('DROP INDEX ipb_address');
+ }
if (pg_index_exists('ipblocks', 'ipb_address_unique' )) {
wfOut( "... have ipb_address_unique\n" );
- } else {
+ }
+ else {
wfOut( "Adding ipb_address_unique index\n" );
dbsource(archive('patch-ipb_address_unique.sql'));
}
@@ -1713,11 +1750,20 @@ function do_postgres_updates() {
# 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: 46891 $',
+ 'sql_date' => '$LastChangedDate: 2009-02-05 22:54:47 -0600 (Thu, 05 Feb 2009) $',
+ ) );
return;
}
-