WIP ViDoTeach REST API: fix not working unsetting in PATCH requests with null value

This commit is contained in:
ralf 2024-05-17 15:59:49 +02:00
parent a5796c8b41
commit 5f795a4379
2 changed files with 24 additions and 0 deletions

View File

@ -370,6 +370,11 @@ class JsBase
$target = $value;
}
}
// if we unset fields stored directly in the database, they will NOT be updated :(
elseif (!$n)
{
$target = null;
}
else
{
unset($parent[$part]);

View File

@ -115,6 +115,25 @@ class MimeMagic
return $key;
}
/**
* Convert a MIME type to all known file extensions
*
* If we cannot map the type to any file extension, we return an empty array.
*
* @param string $_type The MIME type to be mapped to a file extension.
* @return array with possible file extensions
*/
public static function mime2extensions($_type)
{
$type = strtolower($_type);
if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type];
return array_keys(array_filter(self::$mime_extension_map, static function($mime) use ($type)
{
return $mime == $type;
}));
}
/**
* Fix old / aliased mime-types by returning valid/default mime-type
*