MediaWiki  REL1_21
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',           '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( 'enableContentHandlerUseDB' ),
00081 
00082                         array( 'dropField', 'site_stats', 'ss_admins',  'patch-ss_admins.sql' ),
00083                         array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
00084                         array( 'addTable', 'sites',                            'patch-sites.sql' ),
00085                         array( 'addField', 'filearchive',   'fa_sha1',          'patch-fa_sha1.sql' ),
00086                         array( 'addField', 'job',           'job_token',         'patch-job_token.sql' ),
00087                         array( 'addField', 'job',           'job_attempts',       'patch-job_attempts.sql' ),
00088                         array( 'addField', 'uploadstash',      'us_props',      'patch-uploadstash-us_props.sql' ),
00089                         array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ),
00090                         array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase-255.sql' ),
00091 
00092                         // KEEP THIS AT THE BOTTOM!!
00093                         array( 'doRebuildDuplicateFunction' ),
00094 
00095                 );
00096         }
00097 
00103         protected function doNamespaceDefaults() {
00104                 $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
00105                 if ( $meta->defaultValue() != null ) {
00106                         return;
00107                 }
00108 
00109                 $this->applyPatch( 'patch_namespace_defaults.sql', false, "Altering namespace fields with default value" );
00110         }
00111 
00115         protected function doFKRenameDeferr() {
00116                 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
00117                 $row = $meta->fetchRow();
00118                 if ( $row && $row['cnt'] > 0 ) {
00119                         return;
00120                 }
00121 
00122                 $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " );
00123         }
00124 
00128         protected function doFunctions17() {
00129                 $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" );
00130         }
00131 
00136         protected function doSchemaUpgrade17() {
00137                 // check if iwlinks table exists which was added in 1.17
00138                 if ( $this->db->tableExists( 'iwlinks' ) ) {
00139                         return;
00140                 }
00141                 $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" );
00142         }
00143 
00147         protected function doInsertPage0() {
00148                 $this->output( "Inserting page 0 if missing ... " );
00149                 $row = array(
00150                         'page_id' => 0,
00151                         'page_namespace' => 0,
00152                         'page_title' => ' ',
00153                         'page_counter' => 0,
00154                         'page_is_redirect' => 0,
00155                         'page_is_new' => 0,
00156                         'page_random' => 0,
00157                         'page_touched' => $this->db->timestamp(),
00158                         'page_latest' => 0,
00159                         'page_len' => 0
00160                 );
00161                 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
00162                 $this->output( "ok\n" );
00163         }
00164 
00169         protected function doRemoveNotNullEmptyDefaults() {
00170                 $meta = $this->db->fieldInfo( 'categorylinks', 'cl_sortkey_prefix' );
00171                 if ( $meta->isNullable() ) {
00172                         return;
00173                 }
00174                 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false, "Removing not null empty constraints" );
00175         }
00176 
00177         protected function doRemoveNotNullEmptyDefaults2() {
00178                 $meta = $this->db->fieldInfo( 'ipblocks', 'ipb_by_text' );
00179                 if ( $meta->isNullable() ) {
00180                         return;
00181                 }
00182                 $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false, "Removing not null empty constraints" );
00183         }
00184 
00189         protected function doRecentchangesFK2Cascade() {
00190                 $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\'' );
00191                 $row = $meta->fetchRow();
00192                 if ( $row ) {
00193                         return;
00194                 }
00195 
00196                 $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" );
00197         }
00198 
00202         protected function doPageRestrictionsPKUKFix() {
00203                 $this->output( "Altering PAGE_RESTRICTIONS keys ... " );
00204 
00205                 $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \'' .
00206                         strtoupper( $this->db->getDBname() ) .
00207                         '\' AND constraint_name = \'' .
00208                         $this->db->tablePrefix() .
00209                         'PAGE_RESTRICTIONS_PK\' AND rownum = 1'
00210                 );
00211                 $row = $meta->fetchRow();
00212                 if ( $row['column_name'] == 'PR_ID' ) {
00213                         $this->output( "seems to be up to date.\n" );
00214                         return;
00215                 }
00216 
00217                 $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false );
00218                 $this->output( "ok\n" );
00219         }
00220 
00224         protected function doRebuildDuplicateFunction() {
00225                 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" );
00226         }
00227 
00233         public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
00234                 parent::doUpdates( $what );
00235 
00236                 $this->db->query( 'BEGIN fill_wiki_info; END;' );
00237         }
00238 
00242         public function purgeCache() {
00243                 # We can't guarantee that the user will be able to use TRUNCATE,
00244                 # but we know that DELETE is available to us
00245                 $this->output( "Purging caches..." );
00246                 $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ );
00247                 $this->output( "done.\n" );
00248         }
00249 
00250 }