Fix silly bug in fixOldLogEntries

If there are no faulty entries, exit early instead of running a query
with 'log_params' => [], which would throw an exception.

Bug: T228655
Change-Id: I6a0f0439d1f3e18f90075a36894f02090cac9202
This commit is contained in:
Daimona Eaytoy 2019-12-16 13:33:06 +01:00
parent 62f7b574f1
commit 395bb9c7e7

View file

@ -48,9 +48,9 @@ class FixOldLogEntries extends LoggedUpdateMaintenance {
$dbr = wfGetDB( DB_REPLICA, 'vslow' );
$newFormatLike = $dbr->buildLike( $dbr->anyString(), 'historyId', $dbr->anyString() );
// Select all non-legacy entries
$res = $dbr->select(
$res = $dbr->selectFieldValues(
'logging',
[ 'log_params' ],
'log_params',
[
'log_type' => 'abusefilter',
"log_params $newFormatLike"
@ -58,9 +58,13 @@ class FixOldLogEntries extends LoggedUpdateMaintenance {
__METHOD__
);
if ( !$res ) {
return [];
}
$legacyParams = [];
foreach ( $res as $row ) {
$params = unserialize( $row->log_params );
foreach ( $res as $logParams ) {
$params = unserialize( $logParams );
// The script always inserted duplicates with the wrong '\n'
$legacyParams[] = $params['historyId'] . '\n' . $params['newId'];
}
@ -76,7 +80,7 @@ class FixOldLogEntries extends LoggedUpdateMaintenance {
__METHOD__
);
if ( !$this->dryRun ) {
if ( !$this->dryRun && $deleteIDs ) {
// Note that we delete entries with legacy format, which are the ones erroneously inserted
// by the script.
wfGetDB( DB_MASTER )->delete(