MediaWiki
REL1_23
|
00001 <?php 00030 class OracleUpdater extends DatabaseUpdater { 00031 00037 protected $db; 00038 00039 protected function getCoreUpdateList() { 00040 return array( 00041 array( 'disableContentHandlerUseDB' ), 00042 00043 // 1.17 00044 array( 'doNamespaceDefaults' ), 00045 array( 'doFKRenameDeferr' ), 00046 array( 'doFunctions17' ), 00047 array( 'doSchemaUpgrade17' ), 00048 array( 'doInsertPage0' ), 00049 array( 'doRemoveNotNullEmptyDefaults' ), 00050 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ), 00051 00052 //1.18 00053 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ), 00054 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), 00055 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), 00056 array( 'doRecentchangesFK2Cascade' ), 00057 00058 //1.19 00059 array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql' ), 00060 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ), 00061 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ), 00062 array( 'doRemoveNotNullEmptyDefaults2' ), 00063 array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ), 00064 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-us_chunk_inx_field.sql' ), 00065 array( 'addField', 'job', 'job_timestamp', 'patch-job_timestamp_field.sql' ), 00066 array( 'addIndex', 'job', 'i02', 'patch-job_timestamp_index.sql' ), 00067 array( 'doPageRestrictionsPKUKFix' ), 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', 00076 'patch-revision-rev_content_format.sql' ), 00077 array( 'addField', 'revision', 'rev_content_model', 00078 'patch-revision-rev_content_model.sql' ), 00079 array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ), 00080 array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ), 00081 array( 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ), 00082 array( 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ), 00083 array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ), 00084 array( 'enableContentHandlerUseDB' ), 00085 array( 'dropField', 'site_stats', 'ss_admins', 'patch-ss_admins.sql' ), 00086 array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ), 00087 array( 'addTable', 'sites', 'patch-sites.sql' ), 00088 array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ), 00089 array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ), 00090 array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ), 00091 array( 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ), 00092 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ), 00093 array( 'modifyField', 'user_former_groups', 'ufg_group', 00094 'patch-ufg_group-length-increase-255.sql' ), 00095 00096 //1.23 00097 array( 'addIndex', 'logging', 'i06', 'patch-logging_user_text_type_time_index.sql' ), 00098 array( 'addIndex', 'logging', 'i07', 'patch-logging_user_text_time_index.sql' ), 00099 array( 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ), 00100 array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ), 00101 array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ), 00102 00103 // KEEP THIS AT THE BOTTOM!! 00104 array( 'doRebuildDuplicateFunction' ), 00105 00106 ); 00107 } 00108 00114 protected function doNamespaceDefaults() { 00115 $meta = $this->db->fieldInfo( 'page', 'page_namespace' ); 00116 if ( $meta->defaultValue() != null ) { 00117 return; 00118 } 00119 00120 $this->applyPatch( 00121 'patch_namespace_defaults.sql', 00122 false, 00123 'Altering namespace fields with default value' 00124 ); 00125 } 00126 00130 protected function doFKRenameDeferr() { 00131 $meta = $this->db->query( ' 00132 SELECT COUNT(*) cnt 00133 FROM user_constraints 00134 WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' 00135 ); 00136 $row = $meta->fetchRow(); 00137 if ( $row && $row['cnt'] > 0 ) { 00138 return; 00139 } 00140 00141 $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " ); 00142 } 00143 00147 protected function doFunctions17() { 00148 $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" ); 00149 } 00150 00155 protected function doSchemaUpgrade17() { 00156 // check if iwlinks table exists which was added in 1.17 00157 if ( $this->db->tableExists( 'iwlinks' ) ) { 00158 return; 00159 } 00160 $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" ); 00161 } 00162 00166 protected function doInsertPage0() { 00167 $this->output( "Inserting page 0 if missing ... " ); 00168 $row = array( 00169 'page_id' => 0, 00170 'page_namespace' => 0, 00171 'page_title' => ' ', 00172 'page_counter' => 0, 00173 'page_is_redirect' => 0, 00174 'page_is_new' => 0, 00175 'page_random' => 0, 00176 'page_touched' => $this->db->timestamp(), 00177 'page_latest' => 0, 00178 'page_len' => 0 00179 ); 00180 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) ); 00181 $this->output( "ok\n" ); 00182 } 00183 00188 protected function doRemoveNotNullEmptyDefaults() { 00189 $meta = $this->db->fieldInfo( 'categorylinks', 'cl_sortkey_prefix' ); 00190 if ( $meta->isNullable() ) { 00191 return; 00192 } 00193 $this->applyPatch( 00194 'patch_remove_not_null_empty_defs.sql', 00195 false, 00196 'Removing not null empty constraints' 00197 ); 00198 } 00199 00200 protected function doRemoveNotNullEmptyDefaults2() { 00201 $meta = $this->db->fieldInfo( 'ipblocks', 'ipb_by_text' ); 00202 if ( $meta->isNullable() ) { 00203 return; 00204 } 00205 $this->applyPatch( 00206 'patch_remove_not_null_empty_defs2.sql', 00207 false, 00208 'Removing not null empty constraints' 00209 ); 00210 } 00211 00216 protected function doRecentchangesFK2Cascade() { 00217 $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \'' . 00218 strtoupper( $this->db->getDBname() ) . 00219 '\' AND constraint_name = \'' . 00220 $this->db->tablePrefix() . 00221 'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\'' 00222 ); 00223 $row = $meta->fetchRow(); 00224 if ( $row ) { 00225 return; 00226 } 00227 00228 $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" ); 00229 } 00230 00234 protected function doPageRestrictionsPKUKFix() { 00235 $this->output( "Altering PAGE_RESTRICTIONS keys ... " ); 00236 00237 $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \'' . 00238 strtoupper( $this->db->getDBname() ) . 00239 '\' AND constraint_name = \'' . 00240 $this->db->tablePrefix() . 00241 'PAGE_RESTRICTIONS_PK\' AND rownum = 1' 00242 ); 00243 $row = $meta->fetchRow(); 00244 if ( $row['column_name'] == 'PR_ID' ) { 00245 $this->output( "seems to be up to date.\n" ); 00246 00247 return; 00248 } 00249 00250 $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false ); 00251 $this->output( "ok\n" ); 00252 } 00253 00257 protected function doRebuildDuplicateFunction() { 00258 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" ); 00259 } 00260 00266 public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) { 00267 parent::doUpdates( $what ); 00268 00269 $this->db->query( 'BEGIN fill_wiki_info; END;' ); 00270 } 00271 00275 public function purgeCache() { 00276 # We can't guarantee that the user will be able to use TRUNCATE, 00277 # but we know that DELETE is available to us 00278 $this->output( "Purging caches..." ); 00279 $this->db->delete( '/*Q*/' . $this->db->tableName( 'objectcache' ), '*', __METHOD__ ); 00280 $this->output( "done.\n" ); 00281 } 00282 }