MediaWiki
master
|
00001 <?php 00030 class OracleUpdater extends DatabaseUpdater { 00031 00037 protected $db; 00038 00039 protected function getCoreUpdateList() { 00040 return array( 00041 // 1.17 00042 array( 'doNamespaceDefaults' ), 00043 array( 'doFKRenameDeferr' ), 00044 array( 'doFunctions17' ), 00045 array( 'doSchemaUpgrade17' ), 00046 array( 'doInsertPage0' ), 00047 array( 'doRemoveNotNullEmptyDefaults' ), 00048 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ), 00049 00050 //1.18 00051 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ), 00052 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), 00053 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), 00054 array( 'doRecentchangesFK2Cascade' ), 00055 00056 //1.19 00057 array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql'), 00058 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ), 00059 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ), 00060 array( 'doRemoveNotNullEmptyDefaults2' ), 00061 array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ), 00062 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ), 00063 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-us_chunk_inx_field.sql' ), 00064 array( 'addField', 'job', 'job_timestamp', 'patch-job_timestamp_field.sql' ), 00065 array( 'addIndex', 'job', 'i02', 'patch-job_timestamp_index.sql' ), 00066 array( 'doPageRestrictionsPKUKFix' ), 00067 array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ), 00068 00069 //1.20 00070 array( 'addIndex', 'ipblocks', 'i05', 'patch-ipblocks_i05_index.sql' ), 00071 array( 'addIndex', 'revision', 'i05', 'patch-revision_i05_index.sql' ), 00072 array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ), 00073 00074 //1.21 00075 array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ), 00076 array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ), 00077 array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ), 00078 array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ), 00079 array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ), 00080 array( 'dropField', 'site_stats', 'ss_admins', 'patch-ss_admins.sql' ), 00081 array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ), 00082 00083 // KEEP THIS AT THE BOTTOM!! 00084 array( 'doRebuildDuplicateFunction' ), 00085 00086 ); 00087 } 00088 00094 protected function doNamespaceDefaults() { 00095 $meta = $this->db->fieldInfo( 'page', 'page_namespace' ); 00096 if ( $meta->defaultValue() != null ) { 00097 return; 00098 } 00099 00100 $this->applyPatch( 'patch_namespace_defaults.sql', false, "Altering namespace fields with default value" ); 00101 } 00102 00106 protected function doFKRenameDeferr() { 00107 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' ); 00108 $row = $meta->fetchRow(); 00109 if ( $row && $row['cnt'] > 0 ) { 00110 return; 00111 } 00112 00113 $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " ); 00114 } 00115 00119 protected function doFunctions17() { 00120 $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" ); 00121 } 00122 00127 protected function doSchemaUpgrade17() { 00128 // check if iwlinks table exists which was added in 1.17 00129 if ( $this->db->tableExists( 'iwlinks' ) ) { 00130 return; 00131 } 00132 $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" ); 00133 } 00134 00138 protected function doInsertPage0() { 00139 $this->output( "Inserting page 0 if missing ... " ); 00140 $row = array( 00141 'page_id' => 0, 00142 'page_namespace' => 0, 00143 'page_title' => ' ', 00144 'page_counter' => 0, 00145 'page_is_redirect' => 0, 00146 'page_is_new' => 0, 00147 'page_random' => 0, 00148 'page_touched' => $this->db->timestamp(), 00149 'page_latest' => 0, 00150 'page_len' => 0 00151 ); 00152 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) ); 00153 $this->output( "ok\n" ); 00154 } 00155 00160 protected function doRemoveNotNullEmptyDefaults() { 00161 $meta = $this->db->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' ); 00162 if ( $meta->isNullable() ) { 00163 return; 00164 } 00165 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false, "Removing not null empty constraints" ); 00166 } 00167 00168 protected function doRemoveNotNullEmptyDefaults2() { 00169 $meta = $this->db->fieldInfo( 'ipblocks' , 'ipb_by_text' ); 00170 if ( $meta->isNullable() ) { 00171 return; 00172 } 00173 $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false, "Removing not null empty constraints" ); 00174 } 00175 00180 protected function doRecentchangesFK2Cascade() { 00181 $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\'' ); 00182 $row = $meta->fetchRow(); 00183 if ( $row ) { 00184 return; 00185 } 00186 00187 $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" ); 00188 } 00189 00193 protected function doPageRestrictionsPKUKFix() { 00194 $this->output( "Altering PAGE_RESTRICTIONS keys ... " ); 00195 00196 $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' ); 00197 $row = $meta->fetchRow(); 00198 if ( $row['column_name'] == 'PR_ID' ) { 00199 $this->output( "seems to be up to date.\n" ); 00200 return; 00201 } 00202 00203 $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false ); 00204 $this->output( "ok\n" ); 00205 } 00206 00210 protected function doRebuildDuplicateFunction() { 00211 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" ); 00212 } 00213 00219 public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) { 00220 parent::doUpdates( $what ); 00221 00222 $this->db->query( 'BEGIN fill_wiki_info; END;' ); 00223 } 00224 00228 protected function purgeCache() { 00229 # We can't guarantee that the user will be able to use TRUNCATE, 00230 # but we know that DELETE is available to us 00231 $this->output( "Purging caches..." ); 00232 $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ ); 00233 $this->output( "done.\n" ); 00234 } 00235 00236 }