Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/dav/lib/Files/FileSearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if throwing in error is better or simply ignoring it with: return 0;

Copy link
Member Author

@tcitworld tcitworld Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning was indeed that it allows for the throw new \InvalidArgumentException('Invalid property value for ' . $property->name, previous: $e); exception to be thrown, so that the front-end can know something's wrong. Otherwise I might not have found about nextcloud/photos#3187

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this:

throw new \InvalidArgumentException(
    sprintf(
        'Invalid property value for %s: got "%s" (type: %s)',
        $property->name,
        is_scalar($value) ? (string)$value : gettype($value),
        gettype($value)
    )
);

and got 2 errors:
InvalidArgumentException Invalid property value for {http://owncloud.org/ns}size: got "0" (type: string)
InvalidArgumentException Invalid property value for {http://nextcloud.org/ns}metadata-photos-original_date_time: got "2024-10-09T00:00:00Z" (type: string)

I'm not sure if these errors can be safely ignored. If these warnings are not important, I'd prefer they not show up in the log.

case SearchPropertyDefinition::DATATYPE_DATETIME:
if (is_numeric($value)) {
return max(0, 0 + $value);
Expand Down
Loading