From: umherirrender Date: Fri, 17 Apr 2015 16:49:50 +0000 (+0200) Subject: Always set duration/flags of type block for new api logparam style X-Git-Tag: 1.31.0-rc.0~11670^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=9a504d18fb13a6afdc9cc3388a13937d58821bba;p=lhc%2Fweb%2Fwiklou.git Always set duration/flags of type block for new api logparam style Old and very old log params may omit a duration or flags. Always adds these parameters to the output. Also simplify the infinity check (see also I5eb68c1fb6029da8289276ecf7c81330575029ef) and check the return of strtotime. Bug: T92902 Follow-Up: I6846ce09322eb404c506b5a51780a44ce9279fe2 Change-Id: I9109a27f416b002e5c562a1454d8c373dcf98fb4 --- diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index b2397272b0..553747e548 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -295,8 +295,8 @@ class ApiQueryLogEvents extends ApiQueryBase { $vals['pageid'] = intval( $row->page_id ); $vals['logpage'] = intval( $row->log_page ); } - if ( $this->fld_details && $row->log_params !== '' ) { - $vals['params'] = LogFormatter::newFromRow( $row )->formatParametersForApi(); + if ( $this->fld_details ) { + $vals['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi(); } } } diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index 38a279f5f5..07ef24b454 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -187,17 +187,27 @@ class BlockLogFormatter extends LogFormatter { } } - if ( isset( $params['6:array:flags'] ) && !is_array( $params['6:array:flags'] ) ) { - $params['6:array:flags'] = $params['6:array:flags'] === '' - ? array() - : explode( ',', $params['6:array:flags'] ); - } + $subtype = $entry->getSubtype(); + if ( $subtype === 'block' || $subtype === 'reblock' ) { + // Defaults for old log entries missing some fields + $params += array( + '5::duration' => 'infinite', + '6:array:flags' => array(), + ); + + if ( !is_array( $params['6:array:flags'] ) ) { + $params['6:array:flags'] = $params['6:array:flags'] === '' + ? array() + : explode( ',', $params['6:array:flags'] ); + } - if ( isset( $params['5::duration'] ) && - SpecialBlock::parseExpiryInput( $params['5::duration'] ) !== wfGetDB( DB_SLAVE )->getInfinity() - ) { - $ts = wfTimestamp( TS_UNIX, $entry->getTimestamp() ); - $params[':timestamp:expiry'] = strtotime( $params['5::duration'], $ts ); + if ( !wfIsInfinity( $params['5::duration'] ) ) { + $ts = wfTimestamp( TS_UNIX, $entry->getTimestamp() ); + $expiry = strtotime( $params['5::duration'], $ts ); + if ( $expiry !== false && $expiry > 0 ) { + $params[':timestamp:expiry'] = $expiry; + } + } } return $params;