]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix numeric folders throwing on markDirty 23049/head
authorJoas Schilling <coding@schilljs.com>
Thu, 24 Sep 2020 12:58:44 +0000 (14:58 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 25 Sep 2020 13:14:58 +0000 (13:14 +0000)
TypeError: strpos() expects parameter 1 to be string, int given

The problem is that in cacheNode() we strip of any slashes, so
a folder "0/" will be trimmed to "0" and be used as an array key.
Since PHP automatically casts numeric array keys to integers,
you afterwards get $nodePath as int(0). Since it's now a number,
the strpos() function does not accept it anymore. Simply casting
$nodePath to a string again in the foreach solves the issue

Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/Connector/Sabre/CachingTree.php

index 2d68025e3fa270f843ff7cd6fd8654238cd8e74b..e65b0d3b4d1cfda0a58210674185335c3248de19 100644 (file)
@@ -38,4 +38,16 @@ class CachingTree extends Tree {
                }
                $this->cache[trim($path, '/')] = $node;
        }
+
+       public function markDirty($path) {
+               // We don't care enough about sub-paths
+               // flushing the entire cache
+               $path = trim($path, '/');
+               foreach ($this->cache as $nodePath => $node) {
+                       $nodePath = (string) $nodePath;
+                       if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) {
+                               unset($this->cache[$nodePath]);
+                       }
+               }
+       }
 }