r106806 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106805‎ | r106806 | r106807 >
Date:16:11, 20 December 2011
Author:freakolowsky
Status:deferred
Tags:
Comment:
* removed manual cascading of recentchanges on page delete
* fixed purgeCache bug in updater
* TESTED install/update from 1.18/phpunit
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: trunk/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: trunk/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql
___________________________________________________________________
Added: svn:eol-style
17 + native
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -420,7 +420,7 @@
421421 );
422422 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
423423 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;
424 -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;
 424+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;
425425 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
426426 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
427427 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -1176,9 +1176,7 @@
11771177 // a hack for deleting pages, users and images (which have non-nullable FKs)
11781178 // all deletions on these tables have transactions so final failure rollbacks these updates
11791179 $table = $this->tableName( $table );
1180 - if ( $table == $this->tableName( 'page' ) ) {
1181 - $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname );
1182 - } elseif ( $table == $this->tableName( 'user' ) ) {
 1180+ if ( $table == $this->tableName( 'user' ) ) {
11831181 $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname );
11841182 $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname );
11851183 $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname );
Index: trunk/phase3/includes/installer/OracleUpdater.php
@@ -36,6 +36,7 @@
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' ),
4041
4142 //1.19
4243 array( 'addTable', 'config', 'patch-config.sql' ),
@@ -49,7 +50,7 @@
5051 array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ),
5152 array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
5253
53 - // till 2.0 i guess
 54+ // KEEP THIS AT THE BOTTOM!!
5455 array( 'doRebuildDuplicateFunction' ),
5556
5657 );
@@ -159,6 +160,24 @@
160161 }
161162
162163 /**
 164+ * Removed forcing of invalid state on recentchanges_fk2.
 165+ * cascading taken in account in the deleting function
 166+ */
 167+ protected function doRecentchangesFK2Cascade() {
 168+ $this->output( "Altering RECENTCHANGES_FK2 ... " );
 169+
 170+ $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\'' );
 171+ $row = $meta->fetchRow();
 172+ if ( $row ) {
 173+ $this->output( "FK up to date\n" );
 174+ return;
 175+ }
 176+
 177+ $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false );
 178+ $this->output( "ok\n" );
 179+ }
 180+
 181+ /**
163182 * rebuilding of the function that duplicates tables for tests
164183 */
165184 protected function doRebuildDuplicateFunction() {
@@ -178,4 +197,15 @@
179198 $this->db->query( 'BEGIN fill_wiki_info; END;' );
180199 }
181200
 201+ /**
 202+ * Overload: because of the DDL_MODE tablename escaping is a bit dodgy
 203+ */
 204+ protected function purgeCache() {
 205+ # We can't guarantee that the user will be able to use TRUNCATE,
 206+ # but we know that DELETE is available to us
 207+ $this->output( "Purging caches..." );
 208+ $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ );
 209+ $this->output( "done.\n" );
 210+ }
 211+
182212 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r106807* backport of r106806...freakolowsky16:14, 20 December 2011

Status & tagging log