From: Jure Kajzer Date: Tue, 20 Dec 2011 16:11:45 +0000 (+0000) Subject: * removed manual cascading of recentchanges on page delete X-Git-Tag: 1.31.0-rc.0~25866 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=ec53acbede2022d194be15fbd97c248de1f50f94;p=lhc%2Fweb%2Fwiklou.git * removed manual cascading of recentchanges on page delete * fixed purgeCache bug in updater * TESTED install/update from 1.18/phpunit --- diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 664e7da609..701127ed4e 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -1176,9 +1176,7 @@ class DatabaseOracle extends DatabaseBase { // a hack for deleting pages, users and images (which have non-nullable FKs) // all deletions on these tables have transactions so final failure rollbacks these updates $table = $this->tableName( $table ); - if ( $table == $this->tableName( 'page' ) ) { - $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname ); - } elseif ( $table == $this->tableName( 'user' ) ) { + if ( $table == $this->tableName( 'user' ) ) { $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname ); $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname ); $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname ); diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index 1e6e4d2956..d94b47b315 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -36,6 +36,7 @@ class OracleUpdater extends DatabaseUpdater { array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ), array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), + array( 'doRecentchangesFK2Cascade' ), //1.19 array( 'addTable', 'config', 'patch-config.sql' ), @@ -49,7 +50,7 @@ class OracleUpdater extends DatabaseUpdater { array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ), array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ), - // till 2.0 i guess + // KEEP THIS AT THE BOTTOM!! array( 'doRebuildDuplicateFunction' ), ); @@ -158,6 +159,24 @@ class OracleUpdater extends DatabaseUpdater { $this->output( "ok\n" ); } + /** + * Removed forcing of invalid state on recentchanges_fk2. + * cascading taken in account in the deleting function + */ + protected function doRecentchangesFK2Cascade() { + $this->output( "Altering RECENTCHANGES_FK2 ... " ); + + $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\'' ); + $row = $meta->fetchRow(); + if ( $row ) { + $this->output( "FK up to date\n" ); + return; + } + + $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false ); + $this->output( "ok\n" ); + } + /** * rebuilding of the function that duplicates tables for tests */ @@ -178,4 +197,15 @@ class OracleUpdater extends DatabaseUpdater { $this->db->query( 'BEGIN fill_wiki_info; END;' ); } + /** + * Overload: because of the DDL_MODE tablename escaping is a bit dodgy + */ + protected function purgeCache() { + # We can't guarantee that the user will be able to use TRUNCATE, + # but we know that DELETE is available to us + $this->output( "Purging caches..." ); + $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ ); + $this->output( "done.\n" ); + } + } diff --git a/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql b/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql new file mode 100644 index 0000000000..455095180b --- /dev/null +++ b/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql @@ -0,0 +1,5 @@ +define mw_prefix='{$wgDBprefix}'; + +ALTER TABLE &mw_prefix.recentchanges DROP CONSTRAINT &mw_prefix.recentchanges_fk2; +ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; + diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index 6274582321..cf5bf3cfa3 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -420,7 +420,7 @@ CREATE TABLE &mw_prefix.recentchanges ( ); ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id); ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk1 FOREIGN KEY (rc_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp); CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title); CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);