require_once 'convertLinks.inc';
require_once 'userDupes.inc';
-require_once 'deleteDefaultMessages.php';
# Extension updates
require_once( "$IP/includes/Hooks.php" );
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' ),
- array( 'do_unique_pl_tl_il' ),
// 1.15
+ array( 'do_unique_pl_tl_il' ),
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' ),
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' ),
+ array( 'add_table', 'external_user', 'patch-external_user.sql' ),
+ array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
+ array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
),
'sqlite' => array(
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' ),
),
);
$wgExtPGNewFields = array(); // table, column, column attributes; for PostgreSQL
$wgExtPGAlteredFields = array(); // table, column, new type, conversion method; for PostgreSQL
$wgExtNewIndexes = array(); // table, index, dir
+$wgExtModifiedFields = array(); //table, index, dir
# Helper function: check if the given key is present in the updatelog table.
# Obviously, only use this for updates that occur after the updatelog table was
wfOut( "...can't move table $from to $to, $to already exists.\n" );
} else {
wfOut( "Moving table $from to $to..." );
- dbsource( archive($patch), $wgDatabase );
+ $wgDatabase->sourceFile( archive($patch) );
wfOut( "ok\n" );
}
} else {
} else {
wfOut( "Creating $name table..." );
if( $fullpath ) {
- dbsource( $patch, $wgDatabase );
+ $wgDatabase->sourceFile( $patch );
} else {
- dbsource( archive($patch), $wgDatabase );
+ $wgDatabase->sourceFile( archive($patch) );
}
wfOut( "ok\n" );
}
}
+function modify_field($table, $field, $patch, $fullpath=false){
+ global $wgDatabase;
+ if ( !$wgDatabase->tableExists( $table ) ) {
+ wfOut( "...$table table does not exist, skipping modify field patch\n" );
+ } elseif (! $wgDatabase->fieldExists( $table, $field ) ) {
+ wfOut( "...$field field does not exist in $table table, skipping modify field patch\n" );
+ } else {
+ wfOut( "Modifying $field field of table $table..." );
+ if( $fullpath ) {
+ $wgDatabase->sourceFile( $patch );
+ } else {
+ $wgDatabase->sourceFile( archive($patch) );
+ }
+ wfOut( "ok\n" );
+ }
+}
+
+
+
function add_field( $table, $field, $patch, $fullpath=false ) {
global $wgDatabase;
if ( !$wgDatabase->tableExists( $table ) ) {
} else {
wfOut( "Adding $field field to table $table..." );
if( $fullpath ) {
- dbsource( $patch, $wgDatabase );
+ $wgDatabase->sourceFile( $patch );
} else {
- dbsource( archive($patch), $wgDatabase );
+ $wgDatabase->sourceFile( archive($patch) );
}
wfOut( "ok\n" );
}
} else {
wfOut( "Adding $index key to table $table... " );
if( $fullpath ) {
- dbsource( $patch, $wgDatabase );
+ $wgDatabase->sourceFile( $patch );
} else {
- dbsource( archive($patch), $wgDatabase );
+ $wgDatabase->sourceFile( archive($patch) );
}
wfOut( "ok\n" );
}
return true;
}
wfOut( "Creating interwiki table: " );
- dbsource( archive("patch-interwiki.sql") );
+ $wgDatabase->sourceFile( archive("patch-interwiki.sql") );
wfOut( "ok\n" );
wfOut( "Adding default interwiki definitions: " );
- dbsource( "$IP/maintenance/interwiki.sql" );
+ $wgDatabase->sourceFile( "$IP/maintenance/interwiki.sql" );
wfOut( "ok\n" );
}
$meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" );
if( !$meta->isMultipleKey() ) {
wfOut( "Updating indexes to 20031107: " );
- dbsource( archive("patch-indexes.sql") );
+ $wgDatabase->sourceFile( archive("patch-indexes.sql") );
wfOut( "ok\n" );
return true;
}
$meta = $wgDatabase->fieldInfo( "image", "img_major_mime" );
if( !$meta->isMultipleKey() ) {
wfOut( "Updating indexes to 20050912: " );
- dbsource( archive("patch-mimesearch-indexes.sql") );
+ $wgDatabase->sourceFile( archive("patch-mimesearch-indexes.sql") );
wfOut( "ok\n" );
return true;
}
wfOut( "...image primary key already set.\n" );
} else {
wfOut( "Making img_name the primary key... " );
- dbsource( archive("patch-image_name_primary.sql"), $wgDatabase );
+ $wgDatabase->sourceFile( archive("patch-image_name_primary.sql") );
wfOut( "ok\n" );
}
}
wfOut( "...timestamp key on logging already exists.\n" );
} else {
wfOut( "Adding timestamp key on logging table... " );
- dbsource( archive("patch-logging-times-index.sql"), $wgDatabase );
+ $wgDatabase->sourceFile( archive("patch-logging-times-index.sql") );
wfOut( "ok\n" );
}
}
wfOut( "...usertext,timestamp key on archive already exists.\n" );
} else {
wfOut( "Adding usertext,timestamp key on archive table... " );
- dbsource( archive("patch-archive-user-index.sql"), $wgDatabase );
+ $wgDatabase->sourceFile( archive("patch-archive-user-index.sql") );
wfOut( "ok\n" );
}
}
wfOut( "...usertext,timestamp key on image already exists.\n" );
} else {
wfOut( "Adding usertext,timestamp key on image table... " );
- dbsource( archive("patch-image-user-index.sql"), $wgDatabase );
+ $wgDatabase->sourceFile( archive("patch-image-user-index.sql") );
wfOut( "ok\n" );
}
}
wfOut( "...usertext,timestamp key on oldimage already exists.\n" );
} else {
wfOut( "Adding usertext,timestamp key on oldimage table... " );
- dbsource( archive("patch-oldimage-user-index.sql"), $wgDatabase );
+ $wgDatabase->sourceFile( archive("patch-oldimage-user-index.sql") );
wfOut( "ok\n" );
}
}
} else {
wfOut( "Adding wl_notificationtimestamp field for email notification management." );
/* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
- dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-email-notification.sql' ) );
wfOut( "ok\n" );
}
# Check if we need to add talk page rows to the watchlist
global $wgDatabase;
if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
wfOut( "User table contains old email authentication field. Dropping... " );
- dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-email-authentication.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "...user table does not contain old email authentication field.\n" );
wfOut( "$table table has correct $field encoding.\n" );
} else {
wfOut( "Fixing $field encoding on $table table... " );
- dbsource( archive( $patchFile ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( $patchFile ) );
wfOut( "ok\n" );
}
}
global $wgDatabase;
if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
wfOut( "Removing revision.inverse_timestamp and fixing indexes... " );
- dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-inverse_timestamp.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "revision timestamp indexes already up to 2005-03-13\n" );
wfOut( "...rev_text_id already in place.\n" );
} else {
wfOut( "Adding rev_text_id field... " );
- dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-rev_text_id.sql' ) );
wfOut( "ok\n" );
}
}
wfOut( "...already have pagelinks table.\n" );
} else {
wfOut( "Converting links and brokenlinks tables to pagelinks... " );
- dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-pagelinks.sql' ) );
wfOut( "ok\n" );
flush();
if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
wfOut( "Dropping unused img_type field in image table... " );
- dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-drop_img_type.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "No img_type field in image table; Good.\n" );
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' ) );
+ $wgDatabase->sourceFile( archive( 'patch-fix-il_from.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "...il_from OK\n" );
wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" );
}
wfOut( "Adding unique index on user_name... " );
- dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-user_nameindex.sql' ) );
wfOut( "ok\n" );
}
}
}
wfOut( "Adding user_groups table... " );
- dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-user_groups.sql' ) );
wfOut( "ok\n" );
if( !$wgDatabase->tableExists( 'user_rights' ) ) {
if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) {
wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
- dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-user_rights.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
wfOut( "ok\n" );
wfOut( "Re-adding fresh user_groups table... " );
- dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-user_groups.sql' ) );
wfOut( "ok\n" );
wfOut( "***\n" );
if( !$info->nullable() ) {
wfOut( "Making wl_notificationtimestamp nullable... " );
- dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-watchlist-null.sql' ) );
wfOut( "ok\n" );
} else {
wfOut( "...wl_notificationtimestamp is already nullable.\n" );
return;
}
wfOut( "Creating templatelinks table...\n" );
- dbsource( archive('patch-templatelinks.sql'), $wgDatabase );
+ $wgDatabase->sourceFile( archive('patch-templatelinks.sql') );
wfOut( "Populating...\n" );
if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) {
// Slow, replication-friendly update
$info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ );
if( !$info ) {
wfOut( "...index `{$index}` not found; adding..." );
- dbsource( archive( $patch ) );
+ $wgDatabase->sourceFile( archive( $patch ) );
wfOut( "done.\n" );
} else {
wfOut( "...index `{$index}` seems ok.\n" );
}
function do_backlinking_indices_update() {
+ global $wgDatabase;
wfOut( "Checking for backlinking indices...\n" );
if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
!index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
!index_has_field('imagelinks', 'il_to', 'il_from'))
{
- dbsource( archive( 'patch-backlinkindexes.sql' ) );
+ $wgDatabase->sourceFile( archive( 'patch-backlinkindexes.sql' ) );
wfOut( "...backlinking indices updated\n" );
}
}
function do_categorylinks_indices_update() {
+ global $wgDatabase;
wfOut( "Checking for categorylinks indices...\n" );
if (!index_has_field('categorylinks', 'cl_sortkey', 'cl_from'))
{
- dbsource( archive( 'patch-categorylinksindex.sql' ) );
+ $wgDatabase->sourceFile( archive( 'patch-categorylinksindex.sql' ) );
wfOut( "...categorylinks indices updated\n" );
}
}
$info = $wgDatabase->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
if ( !$info )
{
- dbsource( archive( 'patch-filearchive-user-index.sql' ) );
+ $wgDatabase->sourceFile( archive( 'patch-filearchive-user-index.sql' ) );
wfOut( "...filearchive indices updated\n" );
}
}
wfOut( "profiling table has pf_memory field.\n" );
} else {
wfOut( "Adding pf_memory field to table profiling..." );
- dbsource( archive( 'patch-profiling-memory.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-profiling-memory.sql' ) );
wfOut( "ok\n" );
}
}
wfOut( "ok.\n" );
return;
}
-
- global $IP;
- require_once "$IP/maintenance/initStats.inc";
- wfInitStats();
+ SiteStatsInit::doAllAndCommit( false );
}
function do_active_users_init() {
}
function do_all_updates( $shared = false, $purge = true ) {
- global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype, $IP;
+ global $wgNewTables, $wgExtModifiedFields, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype, $IP;
wfRunHooks('LoadExtensionSchemaUpdates');
add_index( $fieldRecord[0], $fieldRecord[1], $fieldRecord[2], true );
flush();
}
+ # Add modified extension fields
+ foreach ( $wgExtModifiedFields as $fieldRecord ) {
+ modify_field($fieldRecord[0], $fieldRecord[1], $fieldRecord[2], true);
+ flush();
+ }
wfOut( "Deleting old default messages (this may take a long time!)..." );
- deleteDefaultMessages();
+ if( !defined( 'MW_NO_SETUP' ) ) {
+ define( 'MW_NO_SETUP', true );
+ }
+ require_once 'deleteDefaultMessages.php';
+ DeleteDefaultMessages::reallyExecute();
wfOut( "Done\n" );
do_stats_init();
wfOut( "...$name table already exists.\n" );
} else {
wfOut( "Creating $name table..." );
- dbsource( archive($patch), $wgDatabase );
- dbsource( archive($patch2), $wgDatabase );
+ $wgDatabase->sourceFile( archive($patch) );
+ $wgDatabase->sourceFile( archive($patch2) );
wfOut( "ok\n" );
wfOut( "Migrating old restrictions to new table..." );
wfOut( "...pl_namespace, tl_namespace, il_to indices are already UNIQUE.\n" );
} else {
wfOut( "Making pl_namespace, tl_namespace and il_to indices UNIQUE... " );
- dbsource( archive( 'patch-pl-tl-il-unique.sql' ), $wgDatabase );
+ $wgDatabase->sourceFile( archive( 'patch-pl-tl-il-unique.sql' ) );
wfOut( "ok\n" );
}
}
array('valid_tag', 'patch-change_tag.sql'),
array('user_properties', 'patch-user_properties.sql'),
array('log_search', 'patch-log_search.sql'),
+ array('l10n_cache', 'patch-l10n_cache.sql'),
);
$newcols = array(
array("revision", "rev_parent_id", "INTEGER DEFAULT NULL"),
array("site_stats", "ss_active_users", "INTEGER DEFAULT '-1'"),
array("user_newtalk", "user_last_timestamp", "TIMESTAMPTZ"),
+ array("logging", "log_user_text", "TEXT NOT NULL DEFAULT ''"),
+ array("logging", "log_page", "INTEGER"),
);
array("recentchanges", "rc_timestamp_bot", "(rc_timestamp) WHERE rc_bot = 0"),
array("templatelinks", "templatelinks_from", "(tl_from)"),
array("watchlist", "wl_user", "(wl_user)"),
+ array("logging", "logging_user_type_time", "(log_user, log_type, log_timestamp)"),
+ array("logging", "logging_page_id_time", "(log_page,log_timestamp)"),
);
$newrules = array(
}
wfOut( "Creating table \"$nt[0]\"\n" );
- dbsource(archive($nt[1]));
+ $wgDatabase->sourceFile(archive($nt[1]));
}
## Needed before newcols
wfOut( "Dropping rule \"archive_delete\"\n" );
$wgDatabase->query("DROP RULE archive_delete ON archive");
}
- dbsource(archive("patch-remove-archive2.sql"));
+ $wgDatabase->sourceFile(archive("patch-remove-archive2.sql"));
}
else
wfOut( "... obsolete table \"archive2\" does not exist\n" );
continue;
}
wfOut( "Adding rule \"$nr[1]\" to table \"$nr[0]\"\n" );
- dbsource(archive($nr[2]));
+ $wgDatabase->sourceFile(archive($nr[2]));
}
- if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
- wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete\n" );
- $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
- $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ".
- "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" );
+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascaded")) {
+ wfOut( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" );
+ }
+ else {
+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
+ $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
+ }
+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascade")) {
+ $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" );
+ }
+ wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete/update\n" );
+ $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded ".
+ "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE" );
}
- else
- wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" );
if (!$wgDatabase->triggerExists("page", "page_deleted")) {
wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
- dbsource(archive('patch-page_deleted.sql'));
+ $wgDatabase->sourceFile(archive('patch-page_deleted.sql'));
}
else
wfOut( "... table \"page\" has \"page_deleted\" trigger\n" );
$fi = $wgDatabase->fieldInfo("recentchanges", "rc_cur_id");
if (!$fi->nullable()) {
wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" );
- dbsource(archive('patch-rc_cur_id-not-null.sql'));
+ $wgDatabase->sourceFile(archive('patch-rc_cur_id-not-null.sql'));
}
else
wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
}
else {
wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
- dbsource(archive('patch-revision_rev_user_fkey.sql'));
+ $wgDatabase->sourceFile(archive('patch-revision_rev_user_fkey.sql'));
}
# Fix ipb_address index
}
else {
wfOut( "Adding ipb_address_unique index\n" );
- dbsource(archive('patch-ipb_address_unique.sql'));
+ $wgDatabase->sourceFile(archive('patch-ipb_address_unique.sql'));
}
global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes;
continue;
}
wfOut( "Creating table \"$nt[0]\"\n" );
- dbsource($nt[1]);
+ $wgDatabase->sourceFile($nt[1]);
}
# Add missing extension fields
foreach ( $wgExtPGNewFields as $nc ) {
$wgDatabase->query( "CREATE INDEX $ni[1] ON $ni[0] $ni[2]" );
}
else {
- dbsource($ni[2]);
+ $wgDatabase->sourceFile($ni[2]);
}
}
# Tweak the page_title tsearch2 trigger to filter out slashes
# This is create or replace, so harmless to call if not needed
- dbsource(archive('patch-ts2pagetitle.sql'));
+ $wgDatabase->sourceFile(archive('patch-ts2pagetitle.sql'));
## 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'));
+ $wgDatabase->sourceFile(archive('patch-tsearch2funcs.sql'));
## Put a new row in the mediawiki_version table
$wgDatabase->insert( 'mediawiki_version',