MediaWiki  REL1_20
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                         // 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 
00073                         // KEEP THIS AT THE BOTTOM!!
00074                         array( 'doRebuildDuplicateFunction' ),
00075 
00076                 );
00077         }
00078 
00084         protected function doNamespaceDefaults() {
00085                 $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
00086                 if ( $meta->defaultValue() != null ) {
00087                         return;
00088                 }
00089 
00090                 $this->applyPatch( 'patch_namespace_defaults.sql', false, "Altering namespace fields with default value" );
00091         }
00092 
00096         protected function doFKRenameDeferr() {
00097                 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
00098                 $row = $meta->fetchRow();
00099                 if ( $row && $row['cnt'] > 0 ) {
00100                         return;
00101                 }
00102 
00103                 $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " );
00104         }
00105 
00109         protected function doFunctions17() {
00110                 $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" );
00111         }
00112 
00117         protected function doSchemaUpgrade17() {
00118                 // check if iwlinks table exists which was added in 1.17
00119                 if ( $this->db->tableExists( 'iwlinks' ) ) {
00120                         return;
00121                 }
00122                 $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" );
00123         }
00124 
00128         protected function doInsertPage0() {
00129                 $this->output( "Inserting page 0 if missing ... " );
00130                 $row = array(
00131                         'page_id' => 0,
00132                         'page_namespace' => 0,
00133                         'page_title' => ' ',
00134                         'page_counter' => 0,
00135                         'page_is_redirect' => 0,
00136                         'page_is_new' => 0,
00137                         'page_random' => 0,
00138                         'page_touched' => $this->db->timestamp(),
00139                         'page_latest' => 0,
00140                         'page_len' => 0
00141                 );
00142                 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
00143                 $this->output( "ok\n" );
00144         }
00145 
00150         protected function doRemoveNotNullEmptyDefaults() {
00151                 $meta = $this->db->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' );
00152                 if ( $meta->isNullable() ) {
00153                         return;
00154                 }
00155                 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false, "Removing not null empty constraints" );
00156         }
00157 
00158         protected function doRemoveNotNullEmptyDefaults2() {
00159                 $meta = $this->db->fieldInfo( 'ipblocks' , 'ipb_by_text' );
00160                 if ( $meta->isNullable() ) {
00161                         return;
00162                 }
00163                 $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false, "Removing not null empty constraints" );
00164         }
00165 
00170         protected function doRecentchangesFK2Cascade() {
00171                 $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\'' );
00172                 $row = $meta->fetchRow();
00173                 if ( $row ) {
00174                         return;
00175                 }
00176 
00177                 $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" );
00178         }
00179 
00183         protected function doPageRestrictionsPKUKFix() {
00184                 $this->output( "Altering PAGE_RESTRICTIONS keys ... " );
00185 
00186                 $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' );
00187                 $row = $meta->fetchRow();
00188                 if ( $row['column_name'] == 'PR_ID' ) {
00189                         $this->output( "seems to be up to date.\n" );
00190                         return;
00191                 }
00192 
00193                 $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false );
00194                 $this->output( "ok\n" );
00195         }
00196 
00200         protected function doRebuildDuplicateFunction() {
00201                 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" );
00202         }
00203 
00209         public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
00210                 parent::doUpdates( $what );
00211 
00212                 $this->db->query( 'BEGIN fill_wiki_info; END;' );
00213         }
00214 
00218         protected function purgeCache() {
00219                 # We can't guarantee that the user will be able to use TRUNCATE,
00220                 # but we know that DELETE is available to us
00221                 $this->output( "Purging caches..." );
00222                 $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ );
00223                 $this->output( "done.\n" );
00224         }
00225 
00226 }