Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php |
— | — | @@ -629,10 +629,32 @@ |
630 | 630 | return array( $obj, array() ); |
631 | 631 | } |
632 | 632 | |
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 | + ); |
634 | 656 | |
635 | 657 | // 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__ ); |
637 | 659 | |
638 | 660 | if (!isset($row) || !isset($row->af_id) || !$row->af_id) |
639 | 661 | return null; |