jenkins-bot has submitted this change and it was merged.

Change subject: Fix parameter order for block logs
......................................................................


Fix parameter order for block logs

The new block log params does not known the message number 4 (which is
index 3), therefore LogFormatter::getMessageParameters adds empty index
to keep the sequence in strong order.
But the loop was starting at index 4, not 3, which skips the needed
empty index 3 for the order.

Due to the missing $4 the legacy log params returning index 3 and 4,
therefore move them one up to match the new numbers.

Also fixed undefined index warnings for api's list=logevents

Follow-Up: Ibc7fcaa5a952ff90d42a6477da4baa429f3de64b
Change-Id: Ie23be129ee2bd1d2bf753c3b5cba293d64b8e0e8
---
M includes/api/ApiQueryLogEvents.php
M includes/logging/BlockLogFormatter.php
M includes/logging/LogFormatter.php
3 files changed, 26 insertions(+), 5 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiQueryLogEvents.php 
b/includes/api/ApiQueryLogEvents.php
index c4eb7a8..adf96fd 100644
--- a/includes/api/ApiQueryLogEvents.php
+++ b/includes/api/ApiQueryLogEvents.php
@@ -310,14 +310,21 @@
                                if ( $action == 'unblock' ) {
                                        break;
                                }
+                               if ( $legacy ) {
+                                       $durationKey = 0;
+                                       $flagsKey = 1;
+                               } else {
+                                       $durationKey = '5::duration';
+                                       $flagsKey = '6::flags';
+                               }
                                $vals2 = array();
-                               $vals2['duration'] = $params[0];
-                               $vals2['flags'] = isset( $params[1] ) ? 
$params[1] : '';
+                               $vals2['duration'] = $params[$durationKey];
+                               $vals2['flags'] = isset( $params[$flagsKey] ) ? 
$params[$flagsKey] : '';
 
                                // Indefinite blocks have no expiry time
-                               if ( SpecialBlock::parseExpiryInput( $params[0] 
) !== wfGetDB( DB_SLAVE )->getInfinity() ) {
+                               if ( SpecialBlock::parseExpiryInput( 
$params[$durationKey] ) !== wfGetDB( DB_SLAVE )->getInfinity() ) {
                                        $vals2['expiry'] = wfTimestamp( 
TS_ISO_8601,
-                                               strtotime( $params[0], 
wfTimestamp( TS_UNIX, $ts ) ) );
+                                               strtotime( 
$params[$durationKey], wfTimestamp( TS_UNIX, $ts ) ) );
                                }
                                $vals[$type] = $vals2;
                                $params = null;
diff --git a/includes/logging/BlockLogFormatter.php 
b/includes/logging/BlockLogFormatter.php
index 13d2183..995b809 100644
--- a/includes/logging/BlockLogFormatter.php
+++ b/includes/logging/BlockLogFormatter.php
@@ -62,6 +62,19 @@
                return $params;
        }
 
+       protected function extractParameters() {
+               $params = parent::extractParameters();
+               // Legacy log params returning the params in index 3 and 4, 
moved to 4 and 5
+               if ( $this->entry->isLegacy() && isset( $params[3] ) ) {
+                       if ( isset( $params[4] ) ) {
+                               $params[5] = $params[4];
+                       }
+                       $params[4] = $params[3];
+                       $params[3] = '';
+               }
+               return $params;
+       }
+
        public function getPreloadTitles() {
                $title = $this->entry->getTarget();
                // Preload user page for non-autoblocks
diff --git a/includes/logging/LogFormatter.php 
b/includes/logging/LogFormatter.php
index b69ccb2..16cf5a1 100644
--- a/includes/logging/LogFormatter.php
+++ b/includes/logging/LogFormatter.php
@@ -456,7 +456,8 @@
                 */
                if ( count( $params ) ) {
                        $max = max( array_keys( $params ) );
-                       for ( $i = 4; $i < $max; $i++ ) {
+                       // index 0 to 2 are added in getMessageParameters
+                       for ( $i = 3; $i < $max; $i++ ) {
                                if ( !isset( $params[$i] ) ) {
                                        $params[$i] = '';
                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/192266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie23be129ee2bd1d2bf753c3b5cba293d64b8e0e8
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to