Index: trunk/extensions/ArticleFeedback/populateAFRevisions.php |
— | — | @@ -40,12 +40,11 @@ |
41 | 41 | |
42 | 42 | $lastRevID = 0; |
43 | 43 | $i = 0; |
44 | | - $dbr = wfGetDB( DB_SLAVE ); |
45 | 44 | $dbw = wfGetDB( DB_MASTER ); |
46 | 45 | $this->output( "Reading data from article_feedback ...\n" ); |
47 | 46 | while ( true ) { |
48 | 47 | // Get the next revision ID |
49 | | - $row = $dbr->selectRow( 'article_feedback', array( 'aa_revision', 'aa_page_id' ), |
| 48 | + $row = $dbw->selectRow( 'article_feedback', array( 'aa_revision', 'aa_page_id' ), |
50 | 49 | "aa_revision > $lastRevID", __METHOD__, |
51 | 50 | array( 'ORDER BY' => 'aa_revision', 'LIMIT' => 1 ) |
52 | 51 | ); |
— | — | @@ -57,7 +56,7 @@ |
58 | 57 | $pageid = intval( $row->aa_page_id ); |
59 | 58 | |
60 | 59 | // Get all article_feedback rows for this revision |
61 | | - $res = $dbr->select( 'article_feedback', |
| 60 | + $res = $dbw->select( 'article_feedback', |
62 | 61 | array( 'aa_rating_id', 'aa_rating_value', 'aa_user_id', 'aa_user_anon_token' ), |
63 | 62 | array( 'aa_revision' => $revid ), |
64 | 63 | __METHOD__ |
Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -37,11 +37,12 @@ |
38 | 38 | $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' ); |
39 | 39 | } |
40 | 40 | |
41 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 41 | + $dbw = wfGetDB( DB_MASTER ); |
42 | 42 | |
43 | 43 | // Query the latest ratings by this user for this page, |
44 | 44 | // possibly for an older revision |
45 | | - $res = $dbr->select( |
| 45 | + // Select from the master to prevent replag-induced bugs |
| 46 | + $res = $dbw->select( |
46 | 47 | 'article_feedback', |
47 | 48 | array( 'aa_rating_id', 'aa_rating_value', 'aa_revision' ), |
48 | 49 | array( |
— | — | @@ -55,6 +56,7 @@ |
56 | 57 | array( |
57 | 58 | 'ORDER BY' => 'aa_revision DESC', |
58 | 59 | 'LIMIT' => count( $wgArticleFeedbackRatings ), |
| 60 | + 'LOCK IN SHARE MODE', // Prevent race conditions |
59 | 61 | ) |
60 | 62 | ); |
61 | 63 | |