X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FdeleteAutoPatrolLogs.php;h=82bb928fb8969e8fd6a9c1b03f82cce4511da26f;hb=6026d27c620c9c5f137007390a6e1b456c751938;hp=c1935a7625dca0a6c9e328551a521590581a432b;hpb=c9d8188f1ee27e8a816949bf6b74e340156aafc7;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/deleteAutoPatrolLogs.php b/maintenance/deleteAutoPatrolLogs.php index c1935a7625..82bb928fb8 100644 --- a/maintenance/deleteAutoPatrolLogs.php +++ b/maintenance/deleteAutoPatrolLogs.php @@ -31,8 +31,7 @@ class DeleteAutoPatrolLogs extends Maintenance { $this->addOption( 'dry-run', 'Print debug info instead of actually deleting' ); $this->addOption( 'check-old', - 'Check old patrol logs (for deleting old format autopatrols).' . - 'Note that this will not delete rows older than 2011 (MediaWiki 1.18).' + 'Check old patrol logs (for deleting old format autopatrols).' ); $this->addOption( 'before', @@ -156,17 +155,27 @@ class DeleteAutoPatrolLogs extends Maintenance { $autopatrols = []; foreach ( $result as $row ) { $last = $row->log_id; - Wikimedia\suppressWarnings(); - $params = unserialize( $row->log_params ); - Wikimedia\restoreWarnings(); + $logEntry = DatabaseLogEntry::newFromRow( $row ); + $params = $logEntry->getParameters(); + if ( !is_array( $params ) ) { + continue; + } - // Skipping really old rows, before 2011 - if ( !is_array( $params ) || !array_key_exists( '6::auto', $params ) ) { + // This logic belongs to PatrolLogFormatter::getMessageKey + // and LogFormatter::extractParameters the 'auto' value is logically presented as key [5]. + // For legacy case the logical key is index + 3, meaning [2]. + // For the modern case, the logical key is index - 1 meaning [6]. + if ( array_key_exists( '6::auto', $params ) ) { + // Between 2011-2016 autopatrol logs + $auto = $params['6::auto'] === true; + } elseif ( $logEntry->isLegacy() === true && array_key_exists( 2, $params ) ) { + // Pre-2011 autopatrol logs + $auto = $params[2] === '1'; + } else { continue; } - $auto = $params['6::auto']; - if ( $auto ) { + if ( $auto === true ) { $autopatrols[] = $row->log_id; } }