db->fieldInfo( 'page', 'page_namespace' ); if ( $meta->defaultValue() != null ) { return; } $this->applyPatch( 'patch_namespace_defaults.sql', false, 'Altering namespace fields with default value' ); } /** * Uniform FK names + deferrable state */ protected function doFKRenameDeferr() { $meta = $this->db->query( ' SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' ); $row = $meta->fetchRow(); if ( $row && $row['cnt'] > 0 ) { return; } $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " ); } /** * Recreate functions to 17 schema layout */ protected function doFunctions17() { $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" ); } /** * Schema upgrade 16->17 * there are no incremental patches prior to this */ protected function doSchemaUpgrade17() { // check if iwlinks table exists which was added in 1.17 if ( $this->db->tableExists( 'iwlinks' ) ) { return; } $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" ); } /** * Insert page (page_id = 0) to prevent FK constraint violation */ protected function doInsertPage0() { $this->output( "Inserting page 0 if missing ... " ); $row = [ 'page_id' => 0, 'page_namespace' => 0, 'page_title' => ' ', 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, 'page_touched' => $this->db->timestamp(), 'page_latest' => 0, 'page_len' => 0 ]; $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', [ 'IGNORE' ] ); $this->output( "ok\n" ); } /** * Remove DEFAULT '' NOT NULL constraints from fields as '' is internally * converted to NULL in Oracle */ protected function doRemoveNotNullEmptyDefaults() { $meta = $this->db->fieldInfo( 'categorylinks', 'cl_sortkey_prefix' ); if ( $meta->isNullable() ) { return; } $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false, 'Removing not null empty constraints' ); } protected function doRemoveNotNullEmptyDefaults2() { $meta = $this->db->fieldInfo( 'ipblocks', 'ipb_by_text' ); if ( $meta->isNullable() ) { return; } $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false, 'Removing not null empty constraints' ); } /** * Removed forcing of invalid state on recentchanges_fk2. * cascading taken in account in the deleting function */ protected function doRecentchangesFK2Cascade() { $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \'' . strtoupper( $this->db->getDBname() ) . '\' AND constraint_name = \'' . $this->db->tablePrefix() . 'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\'' ); $row = $meta->fetchRow(); if ( $row ) { return; } $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" ); } /** * Fixed wrong PK, UK definition */ protected function doPageRestrictionsPKUKFix() { $this->output( "Altering PAGE_RESTRICTIONS keys ... " ); $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \'' . strtoupper( $this->db->getDBname() ) . '\' AND constraint_name = \'' . $this->db->tablePrefix() . 'PAGE_RESTRICTIONS_PK\' AND rownum = 1' ); $row = $meta->fetchRow(); if ( $row['column_name'] == 'PR_ID' ) { $this->output( "seems to be up to date.\n" ); return; } $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false ); $this->output( "ok\n" ); } /** * Add auto-increment triggers */ protected function doAutoIncrementTriggers() { $this->output( "Adding auto-increment triggers ... " ); $meta = $this->db->query( 'SELECT trigger_name FROM user_triggers WHERE table_owner = \'' . strtoupper( $this->db->getDBname() ) . '\' AND trigger_name = \'' . $this->db->tablePrefix() . 'PAGE_DEFAULT_PAGE_ID\'' ); $row = $meta->fetchRow(); if ( $row['column_name'] ) { $this->output( "seems to be up to date.\n" ); return; } $this->applyPatch( 'patch-auto_increment_triggers.sql', false ); $this->output( "ok\n" ); } /** * rebuilding of the function that duplicates tables for tests */ protected function doRebuildDuplicateFunction() { $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" ); } /** * Overload: after this action field info table has to be rebuilt * * @param array $what */ public function doUpdates( array $what = [ 'core', 'extensions', 'purge', 'stats' ] ) { parent::doUpdates( $what ); $this->db->query( 'BEGIN fill_wiki_info; END;' ); } /** * Overload: because of the DDL_MODE tablename escaping is a bit dodgy */ public function purgeCache() { # We can't guarantee that the user will be able to use TRUNCATE, # but we know that DELETE is available to us $this->output( "Purging caches..." ); $this->db->delete( '/*Q*/' . $this->db->tableName( 'objectcache' ), '*', __METHOD__ ); $this->output( "done.\n" ); } }