From 8756987e27fb9d9df77dd10e750c61bd2901e39a Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 17 Apr 2015 18:24:50 +0200 Subject: [PATCH] Fix old log params of log type rights for new api logparam style The log param of right changes can also just be a string. The new api logparam style does not recognize this and shows an error: Argument 1 passed to ApiResult::setIndexedTagName() must be an instance of array, string given Centralize the code in a new helper function and use it also for the gui part. Follow-Up: I6846ce09322eb404c506b5a51780a44ce9279fe2 Change-Id: I4762743b3f43e6ebd806d3ae516507ae66478e96 --- includes/logging/RightsLogFormatter.php | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php index 597bec58e9..f69530ccd7 100644 --- a/includes/logging/RightsLogFormatter.php +++ b/includes/logging/RightsLogFormatter.php @@ -67,20 +67,8 @@ class RightsLogFormatter extends LogFormatter { return $params; } - $oldGroups = $params[3]; - $newGroups = $params[4]; - - // Less old entries - if ( $oldGroups === '' ) { - $oldGroups = array(); - } elseif ( is_string( $oldGroups ) ) { - $oldGroups = array_map( 'trim', explode( ',', $oldGroups ) ); - } - if ( $newGroups === '' ) { - $newGroups = array(); - } elseif ( is_string( $newGroups ) ) { - $newGroups = array_map( 'trim', explode( ',', $newGroups ) ); - } + $oldGroups = $this->makeGroupArray( $params[3] ); + $newGroups = $this->makeGroupArray( $params[4] ); $userName = $this->entry->getTarget()->getText(); if ( !$this->plaintext && count( $oldGroups ) ) { @@ -128,6 +116,9 @@ class RightsLogFormatter extends LogFormatter { } } + $params['4:array:oldgroups'] = $this->makeGroupArray( $params['4:array:oldgroups'] ); + $params['5:array:newgroups'] = $this->makeGroupArray( $params['5:array:newgroups'] ); + return $params; } @@ -141,4 +132,14 @@ class RightsLogFormatter extends LogFormatter { } return $ret; } + + private function makeGroupArray( $group ) { + // Migrate old group params from string to array + if ( $group === '' ) { + $group = array(); + } elseif ( is_string( $group ) ) { + $group = array_map( 'trim', explode( ',', $group ) ); + } + return $group; + } } -- 2.20.1