Skip to content

Commit 2fff9ea

Browse files
authored
Merge pull request #349 from nextcloud/update-searchdav102
update icewind/searchdav to 1.0.2
2 parents 4a0dc80 + aa5f795 commit 2fff9ea

27 files changed

+88
-68
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"deepdiver1975/tarstreamer": "v0.1.0",
2020
"doctrine/dbal": "2.9.2",
2121
"guzzlehttp/guzzle": "6.3.3",
22-
"icewind/searchdav": "1.0.1",
22+
"icewind/searchdav": "1.0.2",
2323
"icewind/streams": "v0.7.1",
2424
"interfasys/lognormalizer": "^v1.0",
2525
"jeremeamia/superclosure": "^2.4",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,27 +1364,27 @@
13641364
},
13651365
{
13661366
"name": "icewind/searchdav",
1367-
"version": "v1.0.1",
1368-
"version_normalized": "1.0.1.0",
1367+
"version": "v1.0.2",
1368+
"version_normalized": "1.0.2.0",
13691369
"source": {
13701370
"type": "git",
13711371
"url": "https://github.com/icewind1991/SearchDAV.git",
1372-
"reference": "b3fde1c79bc9c53f329f8ae1ee93d377903bf616"
1372+
"reference": "7174c023485c23037c6af786fce5a382fc72a75d"
13731373
},
13741374
"dist": {
13751375
"type": "zip",
1376-
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/b3fde1c79bc9c53f329f8ae1ee93d377903bf616",
1377-
"reference": "b3fde1c79bc9c53f329f8ae1ee93d377903bf616",
1376+
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/7174c023485c23037c6af786fce5a382fc72a75d",
1377+
"reference": "7174c023485c23037c6af786fce5a382fc72a75d",
13781378
"shasum": ""
13791379
},
13801380
"require": {
1381-
"php": ">=5.6",
1381+
"php": ">=7.1",
13821382
"sabre/dav": "^3.2.0"
13831383
},
13841384
"require-dev": {
13851385
"phpunit/phpunit": "^4.8"
13861386
},
1387-
"time": "2018-03-22T16:07:21+00:00",
1387+
"time": "2019-11-06T13:15:26+00:00",
13881388
"type": "library",
13891389
"installation-source": "dist",
13901390
"autoload": {

icewind/searchdav/src/Backend/ISearchBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/Backend/SearchPropertyDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/Backend/SearchResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/DAV/DiscoverHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/DAV/PathHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/DAV/QueryParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*

icewind/searchdav/src/DAV/SearchHandler.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
/**
33
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
44
*
@@ -62,11 +62,6 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
6262
}
6363
/** @var BasicSearch $query */
6464
$query = $xml['{DAV:}basicsearch'];
65-
if (!$query->where) {
66-
$response->setStatus(400);
67-
$response->setBody('Parse error: Missing {DAV:}where from {DAV:}basicsearch');
68-
return false;
69-
}
7065
if (!$query->select) {
7166
$response->setStatus(400);
7267
$response->setBody('Parse error: Missing {DAV:}select from {DAV:}basicsearch');
@@ -89,7 +84,8 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
8984
$response->setBody($e->getMessage());
9085
return false;
9186
}
92-
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results, $query->select)), false);
87+
$data = $this->server->generateMultiStatus(iterator_to_array($this->getPropertiesIteratorResults($results,
88+
$query->select)), false);
9389
$response->setBody($data);
9490
return false;
9591
}
@@ -98,9 +94,10 @@ public function handleSearchRequest($xml, ResponseInterface $response) {
9894
* @param BasicSearch $xml
9995
* @param SearchPropertyDefinition[] $allProps
10096
* @return Query
97+
* @throws BadRequest
10198
*/
10299
private function getQueryForXML(BasicSearch $xml, array $allProps) {
103-
$orderBy = array_map(function(\SearchDAV\XML\Order $order) use ($allProps) {
100+
$orderBy = array_map(function (\SearchDAV\XML\Order $order) use ($allProps) {
104101
if (!isset($allProps[$order->property])) {
105102
throw new BadRequest('requested order by property is not a valid property for this scope');
106103
}
@@ -110,7 +107,7 @@ private function getQueryForXML(BasicSearch $xml, array $allProps) {
110107
}
111108
return new Order($prop, $order->order);
112109
}, $xml->orderBy);
113-
$select = array_map(function($propName) use ($allProps) {
110+
$select = array_map(function ($propName) use ($allProps) {
114111
if (!isset($allProps[$propName])) {
115112
return;
116113
}
@@ -122,13 +119,19 @@ private function getQueryForXML(BasicSearch $xml, array $allProps) {
122119
}, $xml->select);
123120
$select = array_filter($select);
124121

125-
$where = $this->transformOperator($xml->where, $allProps);
122+
$where = $xml->where ? $this->transformOperator($xml->where, $allProps) : null;
126123

127124
return new Query($select, $xml->from, $where, $orderBy, $xml->limit);
128125
}
129126

127+
/**
128+
* @param \SearchDAV\XML\Operator $operator
129+
* @param array $allProps
130+
* @return Operator
131+
* @throws BadRequest
132+
*/
130133
private function transformOperator(\SearchDAV\XML\Operator $operator, array $allProps) {
131-
$arguments = array_map(function($argument) use ($allProps) {
134+
$arguments = array_map(function ($argument) use ($allProps) {
132135
if (is_string($argument)) {
133136
if (!isset($allProps[$argument])) {
134137
throw new BadRequest('requested search property is not a valid property for this scope');
@@ -138,10 +141,12 @@ private function transformOperator(\SearchDAV\XML\Operator $operator, array $all
138141
throw new BadRequest('requested search property is not searchable');
139142
}
140143
return $prop;
141-
} else if ($argument instanceof \SearchDAV\XML\Operator) {
142-
return $this->transformOperator($argument, $allProps);
143144
} else {
144-
return $argument;
145+
if ($argument instanceof \SearchDAV\XML\Operator) {
146+
return $this->transformOperator($argument, $allProps);
147+
} else {
148+
return $argument;
149+
}
145150
}
146151
}, $operator->arguments);
147152

0 commit comments

Comments
 (0)