diff options
author | Robin Appelman <robin@icewind.nl> | 2017-03-14 14:42:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-14 14:42:57 +0100 |
commit | 8217b16cfecece7e5f5e6a76b0716ef155ae4b63 (patch) | |
tree | c3ad3720a62cf61b1b8f987ef0a6d7518ff92dcc /apps/dav | |
parent | 8d91c84ec4f60b382729ac0bc8c9ed08a4157236 (diff) | |
parent | e392d02d80fb347a93e57edf009c1f3ef3549415 (diff) | |
download | nextcloud-server-8217b16cfecece7e5f5e6a76b0716ef155ae4b63.tar.gz nextcloud-server-8217b16cfecece7e5f5e6a76b0716ef155ae4b63.zip |
Merge pull request #3824 from nextcloud/dav-search-getlastmodified
fix searching and ordering on getlastmodified
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Files/FileSearchBackend.php | 10 | ||||
-rw-r--r-- | apps/dav/tests/unit/Files/FileSearchBackendTest.php | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index afdb425e8ed..5816c659932 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -113,7 +113,7 @@ class FileSearchBackend implements ISearchBackend { // queryable properties new SearchPropertyDefinition('{DAV:}displayname', true, false, true), new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), - new SearchPropertyDefinition('{DAV:}getlastmodifed', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME), + new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME), new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN), @@ -236,7 +236,7 @@ class FileSearchBackend implements ISearchBackend { return 'name'; case '{DAV:}getcontenttype': return 'mimetype'; - case '{DAV:}getlastmodifed': + case '{DAV:}getlastmodified': return 'mtime'; case FilesPlugin::SIZE_PROPERTYNAME: return 'size'; @@ -261,6 +261,12 @@ class FileSearchBackend implements ISearchBackend { case SearchPropertyDefinition::DATATYPE_INTEGER: case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER: return 0 + $value; + case SearchPropertyDefinition::DATATYPE_DATETIME: + if (is_numeric($value)) { + return 0 + $value; + } + $date = \DateTime::createFromFormat(\DateTime::ATOM, $value); + return ($date instanceof \DateTime) ? $date->getTimestamp() : 0; default: return $value; } diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php index 539344b22d5..7de92c59763 100644 --- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php +++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php @@ -216,7 +216,7 @@ class FileSearchBackendTest extends TestCase { new \OC\Files\Node\Folder($this->rootFolder, $this->view, '/test/path') ])); - $query = $this->getBasicQuery(Operator::OPERATION_GREATER_THAN, '{DAV:}getlastmodifed', 10); + $query = $this->getBasicQuery(Operator::OPERATION_GREATER_THAN, '{DAV:}getlastmodified', 10); $result = $this->search->search($query); $this->assertCount(1, $result); |