diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-10-29 08:33:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 08:33:53 +0100 |
commit | 3b8f83f5af748bbf874b3c5e678de8eccf9b3384 (patch) | |
tree | aaa5ccfcf33cadf0d45d929679b61a1945c53f90 | |
parent | 97fd61ac4504207069ae6005381cb3d5e37814b8 (diff) | |
parent | bc9b223e65afc2691a74b558f6756d359c6c64bf (diff) | |
download | nextcloud-server-3b8f83f5af748bbf874b3c5e678de8eccf9b3384.tar.gz nextcloud-server-3b8f83f5af748bbf874b3c5e678de8eccf9b3384.zip |
Merge pull request #17730 from nextcloud/fix/15048/search_mimetype_like
Fix DAV mimetype search
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index ac64ba5c592..2d9d8f374f7 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -136,16 +136,19 @@ class QuerySearchHelper { $type = $operator->getType(); if ($field === 'mimetype') { if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) { - $value = $this->mimetypeLoader->getId($value); + $value = (int)$this->mimetypeLoader->getId($value); } else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) { // transform "mimetype='foo/%'" to "mimepart='foo'" if (preg_match('|(.+)/%|', $value, $matches)) { $field = 'mimepart'; - $value = $this->mimetypeLoader->getId($matches[1]); + $value = (int)$this->mimetypeLoader->getId($matches[1]); $type = ISearchComparison::COMPARE_EQUAL; - } - if (strpos($value, '%') !== false) { + } else if (strpos($value, '%') !== false) { throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported'); + } else { + $field = 'mimetype'; + $value = (int)$this->mimetypeLoader->getId($value); + $type = ISearchComparison::COMPARE_EQUAL; } } } else if ($field === 'favorite') { |