Skip to content

Commit

Permalink
Merge pull request #1385 from sabre-io/fix/tree-mark-dirty-strpos-int
Browse files Browse the repository at this point in the history
fix: ensure first argument on strpos is a string
  • Loading branch information
phil-davis authored Jan 20, 2022
2 parents 1f9bfa7 + fec8f14 commit 53e4229
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/DAV/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function markDirty($path)
// flushing the entire cache
$path = trim($path, '/');
foreach ($this->cache as $nodePath => $node) {
if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) {
if ('' === $path || $nodePath == $path || 0 === strpos((string) $nodePath, $path.'/')) {
unset($this->cache[$nodePath]);
}
}
Expand Down
14 changes: 13 additions & 1 deletion tests/Sabre/DAV/TreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public function testDeepMove()
$this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted);
}

public function testDeepMoveNumber()
{
$tree = new TreeMock();
$tree->move('1/2', 'hi/sub');

$this->assertArrayHasKey('sub', $tree->getNodeForPath('hi')->newDirectories);
$this->assertTrue($tree->getNodeForPath('1/2')->isDeleted);
}

public function testDelete()
{
$tree = new TreeMock();
Expand Down Expand Up @@ -114,6 +123,9 @@ public function __construct()
new TreeFileTester('2'),
new TreeFileTester('3'),
]),
new TreeDirectoryTester('1', [
new TreeDirectoryTester('2'),
]),
])
);
}
Expand Down Expand Up @@ -169,7 +181,7 @@ class TreeFileTester extends File implements IProperties
{
public $name;
public $data;
public $properties;
public $properties = [];

public function __construct($name, $data = null)
{
Expand Down

0 comments on commit 53e4229

Please sign in to comment.