-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disallow negative mtime in dav search #10835
Conversation
Signed-off-by: Robin Appelman <robin@icewind.nl>
@@ -352,7 +352,7 @@ private function castValue(SearchPropertyDefinition $property, $value) { | |||
return 0 + $value; | |||
case SearchPropertyDefinition::DATATYPE_DATETIME: | |||
if (is_numeric($value)) { | |||
return 0 + $value; | |||
return max(0, 0 + $value); | |||
} | |||
$date = \DateTime::createFromFormat(\DateTime::ATOM, $value); | |||
return ($date instanceof \DateTime) ? $date->getTimestamp() : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently have the situation that every time I start the Nextcloud iOS App, the error "InvalidArgumentException: Invalid type for field mtime" is written to my Nextcloud log, which seems to be connected to #10835. Because the error is caused by method castValue of class FileSearchBackend: It casts the timestamp "0001-12-30T00:49:56+00:49:56" to boolean false. According to the first user contributed note on this page , this happens for timestamps older than the unix epoch. I have very little PHP experience but I fixed this problem by the following change in line 358 , comments or better workarounds are highly appreciated, thanks in advance!
return ($date instanceof \DateTime && $date->getTimestamp()!= false )? $date->getTimestamp() : 0);
stacktrace_InvalidArgumentException.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cviereck Could we ask you to open this as a new issue so it does not get lost. Thanks for the feedback and debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, feel free to make a PR with the proposed changed.
This change solves issues nextcloud#10870, which is caused by method castValue of class FileSearchBackend: It casts the timestamps older than the unix epoch to false., see my comment nextcloud#10835 (comment).
This change solves issues nextcloud#10870, which is caused by method castValue of class FileSearchBackend: It casts the timestamps older than the unix epoch to false., see my comment nextcloud#10835 (comment).
Prevents potential errors from the database when a client provides an invalid mtime