Skip to content

Commit

Permalink
Merge pull request #1023 from nextcloud/metadata-patch
Browse files Browse the repository at this point in the history
update icewind/searchdav to add api required for metadata feature
  • Loading branch information
PVince81 authored Apr 12, 2022
2 parents d80ec1f + ccc26ff commit 6176112
Show file tree
Hide file tree
Showing 32 changed files with 201 additions and 144 deletions.
5 changes: 5 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit2f23f73bc0cc116b4b1eee1521aa8652::getLoader();
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"egulias/email-validator": "3.1.1",
"giggsey/libphonenumber-for-php": "^8.12.37",
"guzzlehttp/guzzle": "^7.4.0",
"icewind/searchdav": "^2.0.0",
"icewind/searchdav": "^3.0",
"icewind/streams": "v0.7.5",
"microsoft/azure-storage-blob": "^1.5",
"nextcloud/lognormalizer": "^1.0",
Expand Down
24 changes: 16 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function getLoader()
set_include_path(implode(PATH_SEPARATOR, $includePaths));

require __DIR__ . '/autoload_static.php';
\Composer\Autoload\ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652::getInitializer($loader)();
call_user_func(\Composer\Autoload\ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);
Expand Down
24 changes: 16 additions & 8 deletions composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1663,27 +1663,31 @@
},
{
"name": "icewind/searchdav",
"version": "v2.0.0",
"version_normalized": "2.0.0.0",
"version": "v3.0.1",
"version_normalized": "3.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SearchDAV.git",
"reference": "c69806d900c2c9a5954bfabc80178d6eb0d63df4"
"reference": "52c8cfc21bd69271f224671c4924d260b0a8d4fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/c69806d900c2c9a5954bfabc80178d6eb0d63df4",
"reference": "c69806d900c2c9a5954bfabc80178d6eb0d63df4",
"url": "https://api.github.com/repos/icewind1991/SearchDAV/zipball/52c8cfc21bd69271f224671c4924d260b0a8d4fb",
"reference": "52c8cfc21bd69271f224671c4924d260b0a8d4fb",
"shasum": ""
},
"require": {
"php": ">=7.1",
"php": ">=7.3 || >=8.0",
"sabre/dav": "^4.0.0"
},
"require-dev": {
"phpunit/phpunit": "^8"
"friendsofphp/php-cs-fixer": "^2",
"php-parallel-lint/php-parallel-lint": "^1.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8",
"psalm/phar": "^4.3"
},
"time": "2020-02-06T13:56:26+00:00",
"time": "2022-04-11T13:02:49+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand All @@ -1702,6 +1706,10 @@
}
],
"description": "sabre/dav plugin to implement rfc5323 SEARCH",
"support": {
"issues": "https://github.com/icewind1991/SearchDAV/issues",
"source": "https://github.com/icewind1991/SearchDAV/tree/v3.0.1"
},
"install-path": "../icewind/searchdav"
},
{
Expand Down
10 changes: 5 additions & 5 deletions composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '609d7c54d2b9a6e39e7ec1e19a126fa3011a624a',
'reference' => '94cc96de7a8f34b4da8e165ec7308a0024a1d9d6',
'name' => 'nextcloud/3rdparty',
'dev' => false,
),
Expand Down Expand Up @@ -209,12 +209,12 @@
'dev_requirement' => false,
),
'icewind/searchdav' => array(
'pretty_version' => 'v2.0.0',
'version' => '2.0.0.0',
'pretty_version' => 'v3.0.1',
'version' => '3.0.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../icewind/searchdav',
'aliases' => array(),
'reference' => 'c69806d900c2c9a5954bfabc80178d6eb0d63df4',
'reference' => '52c8cfc21bd69271f224671c4924d260b0a8d4fb',
'dev_requirement' => false,
),
'icewind/streams' => array(
Expand Down Expand Up @@ -286,7 +286,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '609d7c54d2b9a6e39e7ec1e19a126fa3011a624a',
'reference' => '94cc96de7a8f34b4da8e165ec7308a0024a1d9d6',
'dev_requirement' => false,
),
'nextcloud/lognormalizer' => array(
Expand Down
1 change: 1 addition & 0 deletions icewind/searchdav/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ composer.lock
vendor
coverage.xml
.phpunit.result.cache
*.cache
15 changes: 15 additions & 0 deletions icewind/searchdav/psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
22 changes: 16 additions & 6 deletions icewind/searchdav/src/Backend/ISearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

namespace SearchDAV\Backend;

use Sabre\DAV\INode;
use SearchDAV\Query\Query;

interface ISearchBackend {
/**
* Get the path of the search arbiter of this backend
*
* The search arbiter is the URI that the client will send it's SEARCH requests to
* The search arbiter is the URI that the client will send its SEARCH requests to
* Note that this is not required to be the same as the search scopes which determine what to search in
*
* The returned value should be a path relative the root of the dav server.
Expand All @@ -37,10 +38,10 @@ interface ISearchBackend {
*
* @return string
*/
public function getArbiterPath();
public function getArbiterPath(): string;

/**
* Whether or not the search backend supports search requests on this scope
* Whether the search backend supports search requests on this scope
*
* The scope defines the resource that it being searched, such as a folder or address book.
*
Expand All @@ -54,7 +55,7 @@ public function getArbiterPath();
* @param string|null $path the path of the search scope relative to the dav server, or null if the scope is outside the dav server
* @return bool
*/
public function isValidScope($href, $depth, $path);
public function isValidScope(string $href, $depth, ?string $path): bool;

/**
* List the available properties that can be used in search
Expand All @@ -68,7 +69,7 @@ public function isValidScope($href, $depth, $path);
* @param string|null $path the path of the search scope relative to the dav server, or null if the scope is outside the dav server
* @return SearchPropertyDefinition[]
*/
public function getPropertyDefinitionsForScope($href, $path);
public function getPropertyDefinitionsForScope(string $href, ?string $path): array;

/**
* Preform the search request
Expand All @@ -80,5 +81,14 @@ public function getPropertyDefinitionsForScope($href, $path);
* @param Query $query
* @return SearchResult[]
*/
public function search(Query $query);
public function search(Query $query): array;

/**
* Called by the search plugin once the nodes to be returned have been found.
* This can be used to more efficiently load the requested properties for the results.
*
* @param INode[] $nodes
* @param string[] $requestProperties
*/
public function preloadPropertyFor(array $nodes, array $requestProperties): void;
}
11 changes: 6 additions & 5 deletions icewind/searchdav/src/Backend/SearchPropertyDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SearchPropertyDefinition {
const DATATYPE_STRING = self::XS . 'string';
const DATATYPE_INTEGER = self::XS . 'integer';
const DATATYPE_NONNEGATIVE_INTEGER = self::XS . 'nonNegativeInteger';
const DATATYPE_NON_NEGATIVE_INTEGER = self::XS . 'nonNegativeInteger';
const DATATYPE_DECIMAL = self::XS . 'decimal';
const DATATYPE_DATETIME = self::XS . 'dateTime';
const DATATYPE_BOOLEAN = self::XS . 'boolean';
Expand All @@ -48,13 +49,13 @@ class SearchPropertyDefinition {
* SearchProperty constructor.
*
* @param string $name the name and namespace of the property in clark notation
* @param bool $searchable whether or not this property can be used as part of a search query
* @param bool $selectable whether or not this property can be returned as part of a search result
* @param bool $sortable whether or not this property can be used to sort the search result
* @param bool $searchable whether this property can be used as part of a search query
* @param bool $selectable whether this property can be returned as part of a search result
* @param bool $sortable whether this property can be used to sort the search result
* @param string $dataType the datatype of the property, one of the SearchProperty::DATATYPE_ constants or any XSD datatype in clark notation
* @param bool $caseSensitive whether or not comparisons on the property are case sensitive, only applies to string propertries
* @param bool $caseSensitive whether comparisons on the property are case-sensitive, only applies to string properties
*/
public function __construct($name, $searchable, $selectable, $sortable, $dataType = self::DATATYPE_STRING, $caseSensitive = true) {
public function __construct(string $name, bool $selectable, bool $searchable, bool $sortable, string $dataType = self::DATATYPE_STRING, bool $caseSensitive = true) {
$this->searchable = $searchable;
$this->selectable = $selectable;
$this->sortable = $sortable;
Expand Down
3 changes: 1 addition & 2 deletions icewind/searchdav/src/Backend/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace SearchDAV\Backend;


use Sabre\DAV\INode;

class SearchResult {
Expand All @@ -36,7 +35,7 @@ class SearchResult {
* @param INode $node
* @param string $href
*/
public function __construct(INode $node, $href) {
public function __construct(INode $node, string $href) {
$this->node = $node;
$this->href = $href;
}
Expand Down
9 changes: 2 additions & 7 deletions icewind/searchdav/src/DAV/DiscoverHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(ISearchBackend $searchBackend, PathHelper $pathHelpe
$this->queryParser = $queryParser;
}

public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response) {
public function handelDiscoverRequest($xml, RequestInterface $request, ResponseInterface $response): bool {
if (!isset($xml['{DAV:}basicsearch'])) {
$response->setStatus(400);
$response->setBody('Unexpected xml content for query-schema-discovery, expected basicsearch');
Expand Down Expand Up @@ -97,12 +97,7 @@ private function getBasicSearchForProperties(array $propertyDefinitions): BasicS
foreach ($propertyDefinitions as $propertyDefinition) {
$key = $this->hashDefinition($propertyDefinition);
if (!isset($groups[$key])) {
$desc = new PropDesc();
$desc->dataType = $propertyDefinition->dataType;
$desc->sortable = $propertyDefinition->sortable;
$desc->selectable = $propertyDefinition->selectable;
$desc->searchable = $propertyDefinition->searchable;
$groups[$key] = $desc;
$groups[$key] = new PropDesc($propertyDefinition);
}
$groups[$key]->properties[] = $propertyDefinition->name;
}
Expand Down
2 changes: 1 addition & 1 deletion icewind/searchdav/src/DAV/PathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(Server $server) {
$this->server = $server;
}

public function getPathFromUri($uri): ?string {
public function getPathFromUri(string $uri): ?string {
if (strpos($uri, '://') === false) {
return $uri;
}
Expand Down
Loading

0 comments on commit 6176112

Please sign in to comment.