diff --git a/.patches/fix-cache-for-node.diff b/.patches/fix-cache-for-node.diff new file mode 100644 index 000000000..4f668c7f2 --- /dev/null +++ b/.patches/fix-cache-for-node.diff @@ -0,0 +1,27 @@ +diff --git a/lib/DAV/Tree.php b/lib/DAV/Tree.php +index 65b4583ceb..1483e1bc51 100644 +--- a/lib/DAV/Tree.php ++++ b/lib/DAV/Tree.php +@@ -62,9 +62,21 @@ public function getNodeForPath($path) + return $this->rootNode; + } + +- $parts = explode('/', $path); + $node = $this->rootNode; + ++ // look for any cached parent and collect the parts below the parent ++ $parts = []; ++ $remainingPath = $path; ++ do { ++ list($remainingPath, $baseName) = Uri\split($remainingPath); ++ array_unshift($parts, $baseName); ++ ++ if (isset($this->cache[$remainingPath])) { ++ $node = $this->cache[$remainingPath]; ++ break; ++ } ++ } while ('' !== $remainingPath); ++ + while (count($parts)) { + if (!($node instanceof ICollection)) { + throw new Exception\NotFound('Could not find node at path: '.$path); diff --git a/composer.patches.json b/composer.patches.json index 044d7666f..225e63c4c 100644 --- a/composer.patches.json +++ b/composer.patches.json @@ -1,4 +1,8 @@ { "patches": { + "sabre/dav": { + "Fix getNodeForPath cache": ".patches/fix-cache-for-node.diff" + } + } } diff --git a/composer/installed.json b/composer/installed.json index 5d8a57dae..95145e4c3 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -3912,6 +3912,11 @@ "bin/naturalselection" ], "type": "library", + "extra": { + "patches_applied": { + "Fix getNodeForPath cache": ".patches/fix-cache-for-node.diff" + } + }, "installation-source": "dist", "autoload": { "psr-4": { diff --git a/composer/installed.php b/composer/installed.php index 2c061f32b..0278a36e3 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'd7b9f6f5f0513adc3ed652eb84b1822fb5b53032', + 'reference' => '330abb953111fee49cd2577b42dcd54712bdb8b0', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -310,7 +310,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'd7b9f6f5f0513adc3ed652eb84b1822fb5b53032', + 'reference' => '330abb953111fee49cd2577b42dcd54712bdb8b0', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/sabre/dav/PATCHES.txt b/sabre/dav/PATCHES.txt new file mode 100644 index 000000000..9e202eda2 --- /dev/null +++ b/sabre/dav/PATCHES.txt @@ -0,0 +1,7 @@ +This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches) +Patches applied to this directory: + +Fix getNodeForPath cache +Source: .patches/fix-cache-for-node.diff + + diff --git a/sabre/dav/lib/DAV/Tree.php b/sabre/dav/lib/DAV/Tree.php index 65b4583ce..1483e1bc5 100644 --- a/sabre/dav/lib/DAV/Tree.php +++ b/sabre/dav/lib/DAV/Tree.php @@ -62,9 +62,21 @@ public function getNodeForPath($path) return $this->rootNode; } - $parts = explode('/', $path); $node = $this->rootNode; + // look for any cached parent and collect the parts below the parent + $parts = []; + $remainingPath = $path; + do { + list($remainingPath, $baseName) = Uri\split($remainingPath); + array_unshift($parts, $baseName); + + if (isset($this->cache[$remainingPath])) { + $node = $this->cache[$remainingPath]; + break; + } + } while ('' !== $remainingPath); + while (count($parts)) { if (!($node instanceof ICollection)) { throw new Exception\NotFound('Could not find node at path: '.$path);