From e392d02d80fb347a93e57edf009c1f3ef3549415 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Mar 2017 14:12:40 +0100 Subject: [PATCH] safer casting of datetime Signed-off-by: Robin Appelman --- apps/dav/lib/Files/FileSearchBackend.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index 784047ad25..5816c65993 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -262,7 +262,11 @@ class FileSearchBackend implements ISearchBackend { case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER: return 0 + $value; case SearchPropertyDefinition::DATATYPE_DATETIME: - return \DateTime::createFromFormat(\DateTime::ATOM, $value)->getTimestamp(); + if (is_numeric($value)) { + return 0 + $value; + } + $date = \DateTime::createFromFormat(\DateTime::ATOM, $value); + return ($date instanceof \DateTime) ? $date->getTimestamp() : 0; default: return $value; }