From 88229cacce80d35575679405f3d8f18598312bcc Mon Sep 17 00:00:00 2001 From: Marvin Beym Date: Wed, 23 Oct 2024 13:10:02 +0200 Subject: [PATCH] harden 'template_values' column handling in certificate id migration --- .../Setup/Migration/CertificateIdMigration.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/ILIAS/Certificate/classes/Setup/Migration/CertificateIdMigration.php b/components/ILIAS/Certificate/classes/Setup/Migration/CertificateIdMigration.php index c90d6aebf983..0c1353785747 100644 --- a/components/ILIAS/Certificate/classes/Setup/Migration/CertificateIdMigration.php +++ b/components/ILIAS/Certificate/classes/Setup/Migration/CertificateIdMigration.php @@ -82,8 +82,17 @@ public function step(Environment $environment): void 'SELECT id, template_values FROM il_cert_user_cert WHERE certificate_id IS NULL' ); - while($row = $this->db->fetchAssoc($result)) { - $template_values = json_decode($row['template_values'], true, 512, JSON_THROW_ON_ERROR); + while ($row = $this->db->fetchAssoc($result)) { + try { + $template_values = json_decode( + $row['template_values'] ?? json_encode([], JSON_THROW_ON_ERROR), + true, + 512, + JSON_THROW_ON_ERROR + ); + } catch (JsonException) { + $template_values = []; + } $certificate_id = $this->uuid_factory->uuid4AsString(); $template_values['CERTIFICATE_ID'] = $certificate_id;