disallow negative mtime in dav search#10835
Conversation
Signed-off-by: Robin Appelman <robin@icewind.nl>
| 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.
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.
@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.
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