Skip to content

Commit 53e4229

Browse files
authored
Merge pull request #1385 from sabre-io/fix/tree-mark-dirty-strpos-int
fix: ensure first argument on strpos is a string
2 parents 1f9bfa7 + fec8f14 commit 53e4229

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/DAV/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function markDirty($path)
226226
// flushing the entire cache
227227
$path = trim($path, '/');
228228
foreach ($this->cache as $nodePath => $node) {
229-
if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) {
229+
if ('' === $path || $nodePath == $path || 0 === strpos((string) $nodePath, $path.'/')) {
230230
unset($this->cache[$nodePath]);
231231
}
232232
}

tests/Sabre/DAV/TreeTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ public function testDeepMove()
5858
$this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted);
5959
}
6060

61+
public function testDeepMoveNumber()
62+
{
63+
$tree = new TreeMock();
64+
$tree->move('1/2', 'hi/sub');
65+
66+
$this->assertArrayHasKey('sub', $tree->getNodeForPath('hi')->newDirectories);
67+
$this->assertTrue($tree->getNodeForPath('1/2')->isDeleted);
68+
}
69+
6170
public function testDelete()
6271
{
6372
$tree = new TreeMock();
@@ -114,6 +123,9 @@ public function __construct()
114123
new TreeFileTester('2'),
115124
new TreeFileTester('3'),
116125
]),
126+
new TreeDirectoryTester('1', [
127+
new TreeDirectoryTester('2'),
128+
]),
117129
])
118130
);
119131
}
@@ -169,7 +181,7 @@ class TreeFileTester extends File implements IProperties
169181
{
170182
public $name;
171183
public $data;
172-
public $properties;
184+
public $properties = [];
173185

174186
public function __construct($name, $data = null)
175187
{

0 commit comments

Comments
 (0)