r106807 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106806‎ | r106807 | r106808 >
Date:16:14, 20 December 2011
Author:freakolowsky
Status:resolved (Comments)
Tags:
Comment:
* backport of r106806
* TESTED install
Modified paths:
  • /branches/REL1_18/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /branches/REL1_18/phase3/includes/installer/OracleUpdater.php (modified) (history)
  • /branches/REL1_18/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql (added) (history)
  • /branches/REL1_18/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql
@@ -0,0 +1,5 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+ALTER TABLE &mw_prefix.recentchanges DROP CONSTRAINT &mw_prefix.recentchanges_fk2;
 5+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;
 6+
Property changes on: branches/REL1_18/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql
___________________________________________________________________
Added: svn:eol-style
17 + native
Index: branches/REL1_18/phase3/maintenance/oracle/tables.sql
@@ -386,7 +386,7 @@
387387 );
388388 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
389389 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;
390 -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;
 390+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;
391391 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
392392 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
393393 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
Index: branches/REL1_18/phase3/includes/db/DatabaseOracle.php
@@ -1175,9 +1175,7 @@
11761176 // a hack for deleting pages, users and images (which have non-nullable FKs)
11771177 // all deletions on these tables have transactions so final failure rollbacks these updates
11781178 $table = $this->tableName( $table );
1179 - if ( $table == $this->tableName( 'page' ) ) {
1180 - $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname );
1181 - } elseif ( $table == $this->tableName( 'user' ) ) {
 1179+ if ( $table == $this->tableName( 'user' ) ) {
11821180 $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname );
11831181 $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname );
11841182 $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname );
Index: branches/REL1_18/phase3/includes/installer/OracleUpdater.php
@@ -36,6 +36,9 @@
3737 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
3838 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
3939 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
 40+ array( 'doRecentchangesFK2Cascade' ),
 41+
 42+ // KEEP THIS AT THE BOTTOM!!
4043 array( 'doRebuildDuplicateFunction' ),
4144
4245 );
@@ -135,6 +138,24 @@
136139 }
137140
138141 /**
 142+ * Removed forcing of invalid state on recentchanges_fk2.
 143+ * cascading taken in account in the deleting function
 144+ */
 145+ protected function doRecentchangesFK2Cascade() {
 146+ $this->output( "Altering RECENTCHANGES_FK2 ... " );
 147+
 148+ $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\'' );
 149+ $row = $meta->fetchRow();
 150+ if ( $row ) {
 151+ $this->output( "FK up to date\n" );
 152+ return;
 153+ }
 154+
 155+ $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false );
 156+ $this->output( "ok\n" );
 157+ }
 158+
 159+ /**
139160 * rebuilding of the function that duplicates tables for tests
140161 */
141162 protected function doRebuildDuplicateFunction() {
@@ -154,4 +175,15 @@
155176 $this->db->query( 'BEGIN fill_wiki_info; END;' );
156177 }
157178
 179+ /**
 180+ * Overload: because of the DDL_MODE tablename escaping is a bit dodgy
 181+ */
 182+ protected function purgeCache() {
 183+ # We can't guarantee that the user will be able to use TRUNCATE,
 184+ # but we know that DELETE is available to us
 185+ $this->output( "Purging caches..." );
 186+ $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ );
 187+ $this->output( "done.\n" );
 188+ }
 189+
158190 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r108234* RN for r106807 and r102428 (sry 4 delay)freakolowsky14:50, 6 January 2012
r108667Move RELEASE-NOTES from r108234 as was before 1.17.1...reedy20:13, 11 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106806* removed manual cascading of recentchanges on page delete...freakolowsky16:11, 20 December 2011

Comments

#Comment by Tim Starling (talk | contribs)   06:46, 30 December 2011

Needs release notes. All core changes after the first beta release need release notes.

Status & tagging log