dav icon indicating copy to clipboard operation
dav copied to clipboard

sabre-io/dav/lib/DAV/Tree.php > getNodeForPath function set $node 'path' property to NULL

Open richardleger opened this issue 6 years ago • 1 comments

When sabre-io/dav/lib/DAV/Tree.php > getNodeForPath function is run, it seems returned $node [via $node = $parent->getChild($baseName);] has its 'path' property set to NULL while it shouldn't I believe. This seems to happens for all nodes returned via this function.

Here is an example (partial view of object obtain via var_export function):

"... SambaDAV\Directory::__set_state(array(\n 'entries' => NULL,\n 'userhome' => NULL,\n 'path' => NULL,\n 'uri' => \n SambaDAV\URI::__set_state(array(\n 'parts' => \n array (\n 0 => 'localhost',\n 1 => 'richard',\n ),\n )),\n 'auth' => \n SambaDAV\Auth::__set_state(array( ..."

This is root cause issues as when the function sabre-io/dav/lib\DAV\FSExt\Directory.php > moveInto is triggered (e.g move of folder), it uses the 'path' property of the object node (passed parameter) as source path for the rename function to proceed the folder move. As the value NULL is not a valid path, the rename fails obviously.

function moveInto($targetName, $sourcePath, DAV\INode $sourceNode) {

    // We only support FSExt\Directory or FSExt\File objects, so
    // anything else we want to quickly reject.
    if (!$sourceNode instanceof self && !$sourceNode instanceof File) {
        return false;
    }

    // PHP allows us to access protected properties from other objects, as
    // long as they are defined in a class that has a shared inheritence
    // with the current class.
    rename($sourceNode->path, $this->path . '/' . $targetName);

    return true;

}

richardleger avatar Apr 06 '19 17:04 richardleger

Which version are you using?

See also the following issue and workaround at the end. Does this solve your problem? https://github.com/sabre-io/dav/issues/1024

m-a-v avatar Apr 21 '20 14:04 m-a-v