Merge "Fix parameter order for block logs"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 25 Feb 2015 08:34:27 +0000 (08:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 25 Feb 2015 08:34:27 +0000 (08:34 +0000)
includes/api/ApiQueryLogEvents.php
includes/logging/BlockLogFormatter.php
includes/logging/LogFormatter.php

index c4eb7a8..adf96fd 100644 (file)
@@ -310,14 +310,21 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                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;
index 13d2183..995b809 100644 (file)
@@ -62,6 +62,19 @@ class BlockLogFormatter extends LogFormatter {
                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
index b69ccb2..16cf5a1 100644 (file)
@@ -456,7 +456,8 @@ class LogFormatter {
                 */
                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] = '';
                                }