Use master db for showing log extract on RevDel success page
authorBrian Wolff <bawolff+wn@gmail.com>
Sat, 16 Nov 2013 22:57:33 +0000 (18:57 -0400)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 29 Jan 2014 18:04:04 +0000 (18:04 +0000)
On revision delete success, we show an excerpt from the log,
it is very confusing when that excerpt doesn't include the
action that you just did.

Bug: 57033
Change-Id: Ica79bf76243f7ab7a2a0fb40689c34bd2ffc0297

includes/logging/LogEventsList.php
includes/specials/SpecialRevisiondelete.php

index ead418d..f0f297f 100644 (file)
@@ -502,6 +502,7 @@ class LogEventsList extends ContextSource {
         * - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
         * - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
         * - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest
+        * - useMaster boolean Use master DB
         * @return int Number of total log items (not limited by $lim)
         */
        public static function showLogExtract(
@@ -515,6 +516,7 @@ class LogEventsList extends ContextSource {
                        'wrap' => "$1",
                        'flags' => 0,
                        'useRequestParams' => false,
+                       'useMaster' => false,
                );
                # The + operator appends elements of remaining keys from the right
                # handed array to the left handed, whereas duplicated keys are NOT overwritten.
@@ -548,6 +550,9 @@ class LogEventsList extends ContextSource {
                        $pager->mIsBackwards = false;
                }
 
+               if ( $param['useMaster'] ) {
+                       $pager->mDb = wfGetDB( DB_MASTER );
+               }
                if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
                        $pager->setOffset( $param['offset'] );
                }
index 804f7a9..3599dc6 100644 (file)
@@ -55,6 +55,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        /** The RevDel_List object, storing the list of items to be deleted/undeleted */
        var $list;
 
+       /** Was the DB modified in this request */
+       protected $wasSaved = false;
+
        /**
         * UI labels for each type.
         */
@@ -177,14 +180,24 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                # Show relevant lines from the deletion log
                $deleteLogPage = new LogPage( 'delete' );
                $output->addHTML( "<h2>" . $deleteLogPage->getName()->escaped() . "</h2>\n" );
-               LogEventsList::showLogExtract( $output, 'delete',
-                       $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
+               LogEventsList::showLogExtract(
+                       $output,
+                       'delete',
+                       $this->targetObj,
+                       '', /* user */
+                       array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved )
+               );
                # Show relevant lines from the suppression log
                if ( $user->isAllowed( 'suppressionlog' ) ) {
                        $suppressLogPage = new LogPage( 'suppress' );
                        $output->addHTML( "<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n" );
-                       LogEventsList::showLogExtract( $output, 'suppress',
-                               $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
+                       LogEventsList::showLogExtract(
+                               $output,
+                               'suppress',
+                               $this->targetObj,
+                               '',
+                               array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved )
+                       );
                }
        }
 
@@ -523,6 +536,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        protected function success() {
                $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
                $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeLabels['success'] );
+               $this->wasSaved = true;
                $this->list->reloadFromMaster();
                $this->showForm();
        }