}
}
-
-
function add_field( $table, $field, $patch, $fullpath = false ) {
global $wgDatabase;
if ( !$wgDatabase->tableExists( $table ) ) {
wfOut( "Done.\n" );
}
-
function do_user_update() {
global $wgDatabase;
if ( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
flush();
}
-
wfOut( "Deleting old default messages (this may take a long time!)..." );
if ( !defined( 'MW_NO_SETUP' ) ) {
define( 'MW_NO_SETUP', true );
}
}
-
-
/***********************************************************************
* Start PG stuff
* TODO: merge with above
$res = $wgDatabase->query( sprintf( $q,
$wgDatabase->addQuotes( $table ),
$wgDatabase->addQuotes( $wgDBmwschema ) ) );
- if ( !$res )
+ if ( !$res ) {
return null;
+ }
$cols = array();
while ( $r = $wgDatabase->fetchRow( $res ) ) {
$res = $wgDatabase->query( sprintf( $q,
$wgDatabase->addQuotes( $wgDBmwschema ),
$wgDatabase->addQuotes( $idx ) ) );
- if ( !$res )
+ if ( !$res ) {
return null;
+ }
if ( !( $r = $wgDatabase->fetchRow( $res ) ) ) {
$wgDatabase->freeResult( $res );
return null;
AND attrelid=pg_class.oid
END;
$r2 = $wgDatabase->query( sprintf( $query, $rid ) );
- if ( !$r2 )
+ if ( !$r2 ) {
return null;
+ }
if ( !( $row2 = $wgDatabase->fetchRow( $r2 ) ) ) {
$wgDatabase->freeResult( $r2 );
return null;
$r = $wgDatabase->query( sprintf( $q,
$wgDatabase->addQuotes( $wgDBmwschema ),
$wgDatabase->addQuotes( $fkey ) ) );
- if ( !( $row = $wgDatabase->fetchRow( $r ) ) )
+ if ( !( $row = $wgDatabase->fetchRow( $r ) ) ) {
return null;
+ }
return $row[0];
}
$wgDatabase->addQuotes( $table ),
$wgDatabase->addQuotes( $rule ) ) );
$row = $wgDatabase->fetchRow( $r );
- if ( !$row )
+ if ( !$row ) {
return null;
+ }
$d = $row[0];
$wgDatabase->freeResult( $r );
return $d;
$wgShowExceptionDetails = 1;
# Just in case their LocalSettings.php does not have this:
- if ( !isset( $wgDBmwschema ) )
+ if ( !isset( $wgDBmwschema ) ) {
$wgDBmwschema = 'mediawiki';
+ }
# Verify that this user is configured correctly
$safeuser = $wgDatabase->addQuotes( $wgDBuser );
}
if ( !array_key_exists( 'search_path', $conf ) ) {
$search_path = '';
- }
- else {
+ } else {
$search_path = $conf['search_path'];
}
if ( strpos( $search_path, $wgDBmwschema ) === false ) {
if ( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) {
$wgDatabase->doQuery( "ALTER USER $wgDBuser SET search_path = $search_path" );
$wgDatabase->doQuery( "SET search_path = $search_path" );
- }
- else {
+ } else {
$path = $conf['search_path'];
wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" );
}
wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" );
$wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" );
$wgDatabase->doQuery( "SET $key = '$value'" );
- }
- else {
+ } else {
wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" );
}
}
if ( 'NOT NULL' === $nc[2] ) {
wfOut( "Changing \"$nc[0].$nc[1]\" to not allow NULLs\n" );
$wgDatabase->query( "ALTER TABLE $nc[0] ALTER $nc[1] SET NOT NULL" );
- }
- else {
+ } else {
wfOut( "... column \"$nc[0].$nc[1]\" is already set as NULL\n" );
}
- }
- else {
+ } else {
# # It's NOT NULL - does it need to be NULL?
if ( 'NULL' === $nc[2] ) {
wfOut( "Changing \"$nc[0].$nc[1]\" to allow NULLs\n" );
$wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
$wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
$wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
- }
- else
+ } else {
wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" );
-
+ }
foreach ( $newindexes as $ni ) {
if ( pg_index_exists( $ni[0], $ni[1] ) ) {
if ( $wgDatabase->hasConstraint( "oldimage_oi_name_fkey_cascaded" ) ) {
wfOut( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" );
- }
- else {
+ } else {
if ( $wgDatabase->hasConstraint( "oldimage_oi_name_fkey" ) ) {
$wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
}
if ( !$wgDatabase->triggerExists( "page", "page_deleted" ) ) {
wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
$wgDatabase->sourceFile( archive( 'patch-page_deleted.sql' ) );
- }
- else
+ } 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" );
$wgDatabase->sourceFile( archive( 'patch-rc_cur_id-not-null.sql' ) );
- }
- else
+ } else {
wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
+ }
$pu = pg_describe_index( "pagelink_unique" );
if ( !is_null( $pu ) && ( $pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title" ) ) {
wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" );
$wgDatabase->query( "DROP INDEX pagelink_unique" );
$pu = null;
- }
- else
+ } else {
wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" );
+ }
if ( is_null( $pu ) ) {
wfOut( "Creating index \"pagelink_unique index\"\n" );
$wgDatabase->query( "CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)" );
- }
- else
+ } else {
wfOut( "... index \"pagelink_unique_index\" already exists\n" );
+ }
if ( pg_fkey_deltype( "revision_rev_user_fkey" ) == 'r' ) {
wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" );
- }
- else {
+ } else {
wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
$wgDatabase->sourceFile( archive( 'patch-revision_rev_user_fkey.sql' ) );
}
}
if ( pg_index_exists( 'ipblocks', 'ipb_address_unique' ) ) {
wfOut( "... have ipb_address_unique\n" );
- }
- else {
+ } else {
wfOut( "Adding ipb_address_unique index\n" );
$wgDatabase->sourceFile( archive( 'patch-ipb_address_unique.sql' ) );
}
if ( $fi->is_deferred() && $fi->is_deferrable() ) {
continue;
}
- wfOut( "Altering column \"$dc[0].$dc[1]\" to be DEFERRABLE INITTALLY DEFERRED\n" );
+ wfOut( "Altering column \"$dc[0].$dc[1]\" to be DEFERRABLE INITIALLY DEFERRED\n" );
$conname = $fi->conname();
$clause = $dc[2];
$command = "ALTER TABLE $dc[0] DROP CONSTRAINT $conname";
# # If the server is 8.3 or higher, rewrite the tsearch2 triggers
# # in case they have the old 'default' versions
- if ( $numver >= 8.3 )
+ if ( $numver >= 8.3 ) {
$wgDatabase->sourceFile( archive( 'patch-tsearch2funcs.sql' ) );
+ }
return;
}