Issue Bug Closed

#102104Migration of sys_log entries to a JSON formatted value failes

Stefan Berger 10/06/23, 12:23 updated 07/09/24, 15:19

Description

Hi,

when the sys_log table has a lot records, the migration of sys_log entries to a JSON formatted value failes due to memory limitations.

The process has to be converted using rather the result object than the result array list.

The following will solve the issue in TYPO3\CMS\Install\Updates\SysLogSerializationUpdate

$queryBuilder = $this->getPreparedQueryBuilder();
$result = $queryBuilder
    ->select('uid', 'log_data')
    ->where(
        $queryBuilder->expr()->like('log_data', $queryBuilder->createNamedParameter('a:%'))
    )
    ->executeQuery();

while ($record = $result->fetchAssociative()) {
    $logData = $this->unserializeLogData($record['log_data'] ?? '');
    $connection->update(
        self::TABLE_NAME,
        ['log_data' => json_encode($logData)],
        ['uid' => (int)$record['uid']]
    );
}
// foreach ($this->getRecordsToUpdate() as $record) {
//     $logData = $this->unserializeLogData($record['log_data'] ?? '');
//     $connection->update(
//         self::TABLE_NAME,
//         ['log_data' => json_encode($logData)],
//         ['uid' => (int)$record['uid']]
//     );
// }

Thanks for fixing the issue.

Reviews 2

History 36

  1. Christian Kuhn commented 10/06/23, 16:03

    Good catch and solution suggestion. I’ll try to come up with something.

  2. Gerrit Code Review pushed patch set 1 for main to change 81363 status New Under Review 10/06/23, 16:12

  3. Gerrit Code Review pushed patch set 2 for main to change 81363 10/06/23, 16:14

  4. Gerrit Code Review pushed patch set 1 for 12.4 to change 81364 10/06/23, 16:32

  5. Christian Kuhn commented and changed status Under Review Resolved done 0 % 100 % 10/06/23, 16:45

    Applied in changeset commit:f68260b0bc5a04530621c3cb6a8450d232fbf960.

  6. Benni Mack changed status Resolved Closed 07/09/24, 15:19