MediaWiki  REL1_24
OracleUpdater.php
Go to the documentation of this file.
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             // 1.24
00104             array( 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ),
00105 
00106             // KEEP THIS AT THE BOTTOM!!
00107             array( 'doRebuildDuplicateFunction' ),
00108 
00109         );
00110     }
00111 
00117     protected function doNamespaceDefaults() {
00118         $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
00119         if ( $meta->defaultValue() != null ) {
00120             return;
00121         }
00122 
00123         $this->applyPatch(
00124             'patch_namespace_defaults.sql',
00125             false,
00126             'Altering namespace fields with default value'
00127         );
00128     }
00129 
00133     protected function doFKRenameDeferr() {
00134         $meta = $this->db->query( '
00135             SELECT COUNT(*) cnt
00136             FROM user_constraints
00137             WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\''
00138         );
00139         $row = $meta->fetchRow();
00140         if ( $row && $row['cnt'] > 0 ) {
00141             return;
00142         }
00143 
00144         $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " );
00145     }
00146 
00150     protected function doFunctions17() {
00151         $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" );
00152     }
00153 
00158     protected function doSchemaUpgrade17() {
00159         // check if iwlinks table exists which was added in 1.17
00160         if ( $this->db->tableExists( 'iwlinks' ) ) {
00161             return;
00162         }
00163         $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" );
00164     }
00165 
00169     protected function doInsertPage0() {
00170         $this->output( "Inserting page 0 if missing ... " );
00171         $row = array(
00172             'page_id' => 0,
00173             'page_namespace' => 0,
00174             'page_title' => ' ',
00175             'page_counter' => 0,
00176             'page_is_redirect' => 0,
00177             'page_is_new' => 0,
00178             'page_random' => 0,
00179             'page_touched' => $this->db->timestamp(),
00180             'page_latest' => 0,
00181             'page_len' => 0
00182         );
00183         $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
00184         $this->output( "ok\n" );
00185     }
00186 
00191     protected function doRemoveNotNullEmptyDefaults() {
00192         $meta = $this->db->fieldInfo( 'categorylinks', 'cl_sortkey_prefix' );
00193         if ( $meta->isNullable() ) {
00194             return;
00195         }
00196         $this->applyPatch(
00197             'patch_remove_not_null_empty_defs.sql',
00198             false,
00199             'Removing not null empty constraints'
00200         );
00201     }
00202 
00203     protected function doRemoveNotNullEmptyDefaults2() {
00204         $meta = $this->db->fieldInfo( 'ipblocks', 'ipb_by_text' );
00205         if ( $meta->isNullable() ) {
00206             return;
00207         }
00208         $this->applyPatch(
00209             'patch_remove_not_null_empty_defs2.sql',
00210             false,
00211             'Removing not null empty constraints'
00212         );
00213     }
00214 
00219     protected function doRecentchangesFK2Cascade() {
00220         $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \'' .
00221             strtoupper( $this->db->getDBname() ) .
00222             '\' AND constraint_name = \'' .
00223             $this->db->tablePrefix() .
00224             'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\''
00225         );
00226         $row = $meta->fetchRow();
00227         if ( $row ) {
00228             return;
00229         }
00230 
00231         $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" );
00232     }
00233 
00237     protected function doPageRestrictionsPKUKFix() {
00238         $this->output( "Altering PAGE_RESTRICTIONS keys ... " );
00239 
00240         $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \'' .
00241             strtoupper( $this->db->getDBname() ) .
00242             '\' AND constraint_name = \'' .
00243             $this->db->tablePrefix() .
00244             'PAGE_RESTRICTIONS_PK\' AND rownum = 1'
00245         );
00246         $row = $meta->fetchRow();
00247         if ( $row['column_name'] == 'PR_ID' ) {
00248             $this->output( "seems to be up to date.\n" );
00249 
00250             return;
00251         }
00252 
00253         $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false );
00254         $this->output( "ok\n" );
00255     }
00256 
00260     protected function doRebuildDuplicateFunction() {
00261         $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" );
00262     }
00263 
00269     public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
00270         parent::doUpdates( $what );
00271 
00272         $this->db->query( 'BEGIN fill_wiki_info; END;' );
00273     }
00274 
00278     public function purgeCache() {
00279         # We can't guarantee that the user will be able to use TRUNCATE,
00280         # but we know that DELETE is available to us
00281         $this->output( "Purging caches..." );
00282         $this->db->delete( '/*Q*/' . $this->db->tableName( 'objectcache' ), '*', __METHOD__ );
00283         $this->output( "done.\n" );
00284     }
00285 }