(bug 25592) LogEventsList:showLogExtract should ignore WebRequest
authorBrad Jorsch <bjorsch@wikimedia.org>
Sat, 2 Feb 2013 02:17:02 +0000 (21:17 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 22 Apr 2013 13:42:44 +0000 (09:42 -0400)
LogEventsList:showLogExtract currently pays attention to WebRequest
parameters such as offset, dir, order, and limit (although limit is
typically overridden by callers, and offset sometimes too).

While these make sense for a pager that is driving the whole page, it
doesn't make much sense for the "most recent log entry" boxes that are
displayed using LogEventsList:showLogExtract. So let's have
LogEventsList:showLogExtract ignore these, and for good measure add in a
parameter to use the old behavior in case any caller really needs that.

Change-Id: Id4380cd863ba69fc9b9afb5a0034d82ad4d9cc34

RELEASE-NOTES-1.22
includes/logging/LogEventsList.php

index 13a3c3c..cf31e51 100644 (file)
@@ -31,6 +31,10 @@ production.
   by adding a new configuration variable $wgApplyIpBlocksToXff (disabled by default).
 * The new hook 'APIGetPossibleErrors' to modify the list of possible errors was
   added.
+* (bug 25592) LogEventsList::showLogExtract() will now ignore various
+  Pager-related WebRequest parameters by default, as this is overwhelmingly
+  likely to be what was intended by users of the method. If any caller wishes
+  to use these parameters, the new param 'useRequestParams' may be set to true.
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail. Previously one could still
index ba48bd7..7025332 100644 (file)
@@ -464,6 +464,7 @@ class LogEventsList extends ContextSource {
         *   set to '' to unset offset
         * - 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
         * @return Integer Number of total log items (not limited by $lim)
         */
        public static function showLogExtract(
@@ -475,7 +476,8 @@ class LogEventsList extends ContextSource {
                        'showIfEmpty' => true,
                        'msgKey' => array( '' ),
                        'wrap' => "$1",
-                       'flags' => 0
+                       'flags' => 0,
+                       'useRequestParams' => false,
                );
                # The + operator appends elements of remaining keys from the right
                # handed array to the left handed, whereas duplicated keys are NOT overwritten.
@@ -487,6 +489,7 @@ class LogEventsList extends ContextSource {
                $msgKey = $param['msgKey'];
                $wrap = $param['wrap'];
                $flags = $param['flags'];
+               $useRequestParams = $param['useRequestParams'];
                if ( !is_array( $msgKey ) ) {
                        $msgKey = array( $msgKey );
                }
@@ -500,6 +503,13 @@ class LogEventsList extends ContextSource {
                # Insert list of top 50 (or top $lim) items
                $loglist = new LogEventsList( $context, null, $flags );
                $pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
+               if ( !$useRequestParams ) {
+                       # Reset vars that may have been taken from the request
+                       $pager->mLimit = 50;
+                       $pager->mDefaultLimit = 50;
+                       $pager->mOffset = "";
+                       $pager->mIsBackwards = false;
+               }
                if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset
                        $pager->setOffset( $param['offset'] );
                }