Bug #92501

TYPO3 v9 Migration-Class SeparateSysHistoryFromSysLogUpdate causes exception on invalid log-data entries

Added by Gabriel Kaufmann / Typoworx NewMedia 20 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
-
Start date:
2020-10-07
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I've been running TYPO3 Migration through TYPO3 v9 and Upgrade-Wizard caused Exception in Migation 'SeparateSysHistoryFromSysLogUpdate'.

Caused by this piece of code in method moveDataFromSysLogToSysHistory

$logData = $row['log_data'] !== null ? (array)unserialize($row['log_data'], ['allowed_classes' => false]) : [];

Later on calling the method updateTablesAndTrackProgress will rise an exception, as in my case for some reason the 'log_data' was not unserializeable, but the function expects this argument to be an array!

There are two points how this cloud be fixed and improved fixed:

1. Improve unserialize (code pieve aboce) like this, as it is more failure proof and better concept of code-handling:
@
$logData = [];
if($row['log_data'] !== null) {
$logData = (array)unserialize($row['log_data'], ['allowed_classes' => false]);
}
@

or even better and cleaner:
@
$logData = [];
if($row['log_data'] !== null) {
if(!!($tmp = (array)unserialize($row['log_data'], ['allowed_classes' => false])) {
$row['log_data'] = $tmp;
}
}
@

2. there's already a try/catch around updateTablesAndTrackProgress,
but we could catch the TypeError separately and may be create some kind of logging or report which records where failing.

Simply add this right before the existing catch \Exception

} catch (\TypeError $e) {
// ignore, log, create report for Migration?!
} catch (\Exception $up) {
$connection->rollBack();
throw ($up);
}

Also available in: Atom PDF