MediaWiki
REL1_19
|
00001 <?php 00015 class OracleUpdater extends DatabaseUpdater { 00016 00022 protected $db; 00023 00024 protected function getCoreUpdateList() { 00025 return array( 00026 // 1.17 00027 array( 'doNamespaceDefaults' ), 00028 array( 'doFKRenameDeferr' ), 00029 array( 'doFunctions17' ), 00030 array( 'doSchemaUpgrade17' ), 00031 array( 'doInsertPage0' ), 00032 array( 'doRemoveNotNullEmptyDefaults' ), 00033 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ), 00034 00035 //1.18 00036 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ), 00037 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), 00038 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), 00039 array( 'doRecentchangesFK2Cascade' ), 00040 00041 //1.19 00042 array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql'), 00043 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ), 00044 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ), 00045 array( 'doRemoveNotNullEmptyDefaults2' ), 00046 array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ), 00047 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ), 00048 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-us_chunk_inx_field.sql' ), 00049 array( 'addField', 'job', 'job_timestamp', 'patch-job_timestamp_field.sql' ), 00050 array( 'addIndex', 'job', 'i02', 'patch-job_timestamp_index.sql' ), 00051 array( 'doPageRestrictionsPKUKFix' ), 00052 array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ), 00053 00054 // KEEP THIS AT THE BOTTOM!! 00055 array( 'doRebuildDuplicateFunction' ), 00056 00057 ); 00058 } 00059 00065 protected function doNamespaceDefaults() { 00066 $this->output( "Altering namespace fields with default value ... " ); 00067 $meta = $this->db->fieldInfo( 'page', 'page_namespace' ); 00068 if ( $meta->defaultValue() != null ) { 00069 $this->output( "defaults seem to present on namespace fields\n" ); 00070 return; 00071 } 00072 00073 $this->applyPatch( 'patch_namespace_defaults.sql', false ); 00074 $this->output( "ok\n" ); 00075 } 00076 00080 protected function doFKRenameDeferr() { 00081 $this->output( "Altering foreign keys ... " ); 00082 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' ); 00083 $row = $meta->fetchRow(); 00084 if ( $row && $row['cnt'] > 0 ) { 00085 $this->output( "at least one FK is deferrable, considering up to date\n" ); 00086 return; 00087 } 00088 00089 $this->applyPatch( 'patch_fk_rename_deferred.sql', false ); 00090 $this->output( "ok\n" ); 00091 } 00092 00096 protected function doFunctions17() { 00097 $this->output( "Recreating functions ... " ); 00098 $this->applyPatch( 'patch_create_17_functions.sql', false ); 00099 $this->output( "ok\n" ); 00100 } 00101 00106 protected function doSchemaUpgrade17() { 00107 $this->output( "Updating schema to 17 ... " ); 00108 // check if iwlinks table exists which was added in 1.17 00109 if ( $this->db->tableExists( 'iwlinks' ) ) { 00110 $this->output( "schema seem to be up to date.\n" ); 00111 return; 00112 } 00113 $this->applyPatch( 'patch_16_17_schema_changes.sql', false ); 00114 $this->output( "ok\n" ); 00115 } 00116 00120 protected function doInsertPage0() { 00121 $this->output( "Inserting page 0 if missing ... " ); 00122 $row = array( 00123 'page_id' => 0, 00124 'page_namespace' => 0, 00125 'page_title' => ' ', 00126 'page_counter' => 0, 00127 'page_is_redirect' => 0, 00128 'page_is_new' => 0, 00129 'page_random' => 0, 00130 'page_touched' => $this->db->timestamp(), 00131 'page_latest' => 0, 00132 'page_len' => 0 00133 ); 00134 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) ); 00135 $this->output( "ok\n" ); 00136 } 00137 00142 protected function doRemoveNotNullEmptyDefaults() { 00143 $this->output( "Removing not null empty constraints ... " ); 00144 $meta = $this->db->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' ); 00145 if ( $meta->isNullable() ) { 00146 $this->output( "constraints seem to be removed\n" ); 00147 return; 00148 } 00149 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false ); 00150 $this->output( "ok\n" ); 00151 } 00152 protected function doRemoveNotNullEmptyDefaults2() { 00153 $this->output( "Removing not null empty constraints ... " ); 00154 $meta = $this->db->fieldInfo( 'ipblocks' , 'ipb_by_text' ); 00155 if ( $meta->isNullable() ) { 00156 $this->output( "constraints seem to be removed\n" ); 00157 return; 00158 } 00159 $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false ); 00160 $this->output( "ok\n" ); 00161 } 00162 00167 protected function doRecentchangesFK2Cascade() { 00168 $this->output( "Altering RECENTCHANGES_FK2 ... " ); 00169 00170 $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\'' ); 00171 $row = $meta->fetchRow(); 00172 if ( $row ) { 00173 $this->output( "FK up to date\n" ); 00174 return; 00175 } 00176 00177 $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false ); 00178 $this->output( "ok\n" ); 00179 } 00180 00184 protected function doPageRestrictionsPKUKFix() { 00185 $this->output( "Altering PAGE_RESTRICTIONS keys ... " ); 00186 00187 $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \''.strtoupper($this->db->getDBname()).'\' AND constraint_name = \'MW_PAGE_RESTRICTIONS_PK\' AND rownum = 1' ); 00188 $row = $meta->fetchRow(); 00189 if ( $row['column_name'] == 'PR_ID' ) { 00190 $this->output( "seems to be up to date.\n" ); 00191 return; 00192 } 00193 00194 $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false ); 00195 $this->output( "ok\n" ); 00196 } 00197 00201 protected function doRebuildDuplicateFunction() { 00202 $this->output( "Rebuilding duplicate function ... " ); 00203 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false ); 00204 $this->output( "ok\n" ); 00205 } 00206 00212 public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) { 00213 parent::doUpdates( $what ); 00214 00215 $this->db->query( 'BEGIN fill_wiki_info; END;' ); 00216 } 00217 00221 protected function purgeCache() { 00222 # We can't guarantee that the user will be able to use TRUNCATE, 00223 # but we know that DELETE is available to us 00224 $this->output( "Purging caches..." ); 00225 $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ ); 00226 $this->output( "done.\n" ); 00227 } 00228 00229 }