Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure first argument on strpos is a string #1385

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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