From 2e305ded71ecabd723b59fe570cfbfc953514272 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Tue, 23 Oct 2018 14:59:50 +0200 Subject: [PATCH] HFP-2328 Reset metadata fields if needed --- h5p-metadata.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/h5p-metadata.class.php b/h5p-metadata.class.php index a7c42ac..6884e0e 100644 --- a/h5p-metadata.class.php +++ b/h5p-metadata.class.php @@ -85,13 +85,13 @@ abstract class H5PMetadata { continue; } - if (isset($metadata[$key])) { + if ($metadata[$key] === null || isset($metadata[$key])) { $value = $metadata[$key]; $db_field_name = strtolower(preg_replace('/(? $config['maxLength']) { + if ($value !== null && strlen($value) > $config['maxLength']) { $value = mb_substr($value, 0, $config['maxLength']); } $types[] = '%s'; @@ -103,7 +103,7 @@ abstract class H5PMetadata { break; case 'json': - $value = json_encode($value); + $value = ($value !== null) ? json_encode($value) : null; $types[] = '%s'; break; }