r52048 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52047‎ | r52048 | r52049 >
Date:11:50, 17 June 2009
Author:werdna
Status:ok
Tags:
Comment:
Fixes from bug 19135:
* Load abuse filter data from the master for edits, prevents unintended reversion in the case of replication lag.
* Load explicit field list, preventing another issue seen on Wikimedia and described in the comments.
Modified paths:
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php
@@ -629,10 +629,32 @@
630630 return array( $obj, array() );
631631 }
632632
633 - $dbr = wfGetDB( DB_SLAVE );
 633+ // Load from master to avoid unintended reversions where there's replication lag.
 634+ $dbr = wfGetDB( DB_MASTER );
 635+
 636+ // Load certain fields only. This prevents a condition seen on Wikimedia where
 637+ // a schema change adding a new field caused that extra field to be selected.
 638+ // Since the selected row may be inserted back into the database, this will cause
 639+ // an SQL error if, say, one server has the updated schema but another does not.
 640+ $loadFields = array(
 641+ 'af_id',
 642+ 'af_pattern',
 643+ 'af_user',
 644+ 'af_user_text',
 645+ 'af_timestamp',
 646+ 'af_enabled',
 647+ 'af_comments',
 648+ 'af_public_comments',
 649+ 'af_hidden',
 650+ 'af_hit_count',
 651+ 'af_throttled',
 652+ 'af_deleted',
 653+ 'af_actions',
 654+ 'af_global',
 655+ );
634656
635657 // Load the main row
636 - $row = $dbr->selectRow( 'abuse_filter', '*', array( 'af_id' => $id ), __METHOD__ );
 658+ $row = $dbr->selectRow( 'abuse_filter', $loadFields, array( 'af_id' => $id ), __METHOD__ );
637659
638660 if (!isset($row) || !isset($row->af_id) || !$row->af_id)
639661 return null;

Status & tagging log