Skip to content

Commit

Permalink
harden 'template_values' column handling in certificate id migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mBeym authored and mjansenDatabay committed Oct 23, 2024
1 parent 42eec46 commit 88229ca
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 88229ca

Please sign in to comment.