HFP-2328 Reset metadata fields if needed

semi-fullscreen
Paal Joergensen 2018-10-23 14:59:50 +02:00
parent f661248b5a
commit 2e305ded71
1 changed files with 3 additions and 3 deletions

View File

@ -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('/(?<!^)[A-Z]/', '_$0', $key));
switch ($config['type']) {
case 'text':
if (strlen($value) > $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;
}