Merge pull request #17731 from nextcloud/backport/17730/stable17
[stable17] Fix DAV mimetype search
This commit is contained in:
commit
d30f86e936
1 changed files with 7 additions and 4 deletions
|
@ -136,16 +136,19 @@ class QuerySearchHelper {
|
||||||
$type = $operator->getType();
|
$type = $operator->getType();
|
||||||
if ($field === 'mimetype') {
|
if ($field === 'mimetype') {
|
||||||
if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) {
|
if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) {
|
||||||
$value = $this->mimetypeLoader->getId($value);
|
$value = (int)$this->mimetypeLoader->getId($value);
|
||||||
} else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) {
|
} else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) {
|
||||||
// transform "mimetype='foo/%'" to "mimepart='foo'"
|
// transform "mimetype='foo/%'" to "mimepart='foo'"
|
||||||
if (preg_match('|(.+)/%|', $value, $matches)) {
|
if (preg_match('|(.+)/%|', $value, $matches)) {
|
||||||
$field = 'mimepart';
|
$field = 'mimepart';
|
||||||
$value = $this->mimetypeLoader->getId($matches[1]);
|
$value = (int)$this->mimetypeLoader->getId($matches[1]);
|
||||||
$type = ISearchComparison::COMPARE_EQUAL;
|
$type = ISearchComparison::COMPARE_EQUAL;
|
||||||
}
|
} else if (strpos($value, '%') !== false) {
|
||||||
if (strpos($value, '%') !== false) {
|
|
||||||
throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported');
|
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') {
|
} else if ($field === 'favorite') {
|
||||||
|
|
Loading…
Reference in a new issue