Skip to content

Commit 96beacb

Browse files
committed
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 /var/www/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 <[email protected]>
1 parent 0c6e396 commit 96beacb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ private function castValue(SearchPropertyDefinition $property, $value) {
482482
case SearchPropertyDefinition::DATATYPE_DECIMAL:
483483
case SearchPropertyDefinition::DATATYPE_INTEGER:
484484
case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER:
485-
return 0 + $value;
485+
if (is_numeric($value)) {
486+
return 0 + $value;
487+
}
488+
throw new \Error("Value for numeric datatype is not numeric");
486489
case SearchPropertyDefinition::DATATYPE_DATETIME:
487490
if (is_numeric($value)) {
488491
return max(0, 0 + $value);

0 commit comments

Comments
 (0)