From 974cfef2142889ef7ec6e1108fa2cd08787a6bb0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 19 Sep 2025 11:55:25 +0200 Subject: [PATCH] fix(metadata): properly handle casting non-numeric values in search operations with custom metadata If a metadata property is declared with a number type but the value provided are not numeric, it logs "A non-numeric value encountered at nextcloud/apps/dav/lib/Files/FileSearchBackend.php#486" instead of throwing a proper error. Now with a proper error we have the proper exception being thrown: InvalidArgumentException Invalid property value for {http://nextcloud.org/ns}metadata-photos-original_date_time Signed-off-by: Thomas Citharel --- apps/dav/lib/Files/FileSearchBackend.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index eb548bbd55c0d..987d07d29a6be 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -482,7 +482,10 @@ private function castValue(SearchPropertyDefinition $property, $value) { case SearchPropertyDefinition::DATATYPE_DECIMAL: case SearchPropertyDefinition::DATATYPE_INTEGER: case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER: - return 0 + $value; + if (is_numeric($value)) { + return 0 + $value; + } + throw new \Error('Value for numeric datatype is not numeric'); case SearchPropertyDefinition::DATATYPE_DATETIME: if (is_numeric($value)) { return max(0, 0 + $value);