Avoid using DB_MASTER in SpecialEditWatchlist::getWatchlist()
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 26 Aug 2015 23:54:23 +0000 (16:54 -0700)
committerKrinkle <krinklemail@gmail.com>
Thu, 27 Aug 2015 01:09:11 +0000 (01:09 +0000)
* Only use it on POST requests, where the submit callback really
  wants the latest data. The form data will be lagged by user
  delay anyway, so using the slave there does not change much.
  ChronologyProtector already handles the user seeing their
  *own* changes for consecutive updates.

Bug: T92357
Change-Id: I50274ad5f67f6445a89c9d8d6f01d3fca1e9002b

includes/specials/SpecialEditWatchlist.php

index 3d68813..74662ae 100644 (file)
@@ -299,7 +299,9 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         */
        private function getWatchlist() {
                $list = array();
-               $dbr = wfGetDB( DB_MASTER );
+
+               $index = $this->getRequest()->wasPosted() ? DB_MASTER : DB_SLAVE;
+               $dbr = wfGetDB( $index );
 
                $res = $dbr->select(
                        'watchlist',
@@ -312,6 +314,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                );
 
                if ( $res->numRows() > 0 ) {
+                       /** @var Title[] $titles */
                        $titles = array();
                        foreach ( $res as $row ) {
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );