You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until now in our usage of sabre/dav the error only occurred in the function 'markDirty' from class Sabre\DAV\Tree and only when using php 8(8.0.10). Under php 7(7.4.21) it works fine.
The use of strpos in markDirty Sabre\DAV\Tree causes errors, because $nodePath can be an integer. This is because php casts all array keys to integers, whenever possible. So, if the key '1' gets set for $this->cache, it will become $this->cache[1] instead of $this->cache['1']. So, when the part of the path is only a number this error occurs.
The function reads this key and uses it in strpos. Because php 8 became more strict for types, it causes an error. We are using sabre/dav 4.1.5, but the error occurs in 4.1.1 as well.
The line "$nodePath = (string)$nodePath;" fixes this error.
public function markDirty($path)
{
$path = trim($path, '/');
foreach ($this->cache as $nodePath => $node) {
$nodePath = (string)$nodePath; // PHP 8 override bugfix: strpos with integer $haystack causes error
if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path . '/')) {
unset($this->cache[$nodePath]);
}
}
}
Sabre/dav debug exception:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:sabredav-version>4.1.5</s:sabredav-version>
<s:exception>TypeError</s:exception>
<s:message>strpos(): Argument #1 ($haystack) must be of type string, int given</s:message>
<s:file>C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\Tree.php</s:file>
<s:line>237</s:line>
<s:code>0</s:code>
<s:stacktrace>#0 C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\Tree.php(237): strpos(16, '16/85/Kalkulati...')
#1 C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\Server.php(1104): Sabre\DAV\Tree->markDirty('16/85/Kalkulati...')
#2 C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\CorePlugin.php(504): Sabre\DAV\Server->createFile('16/85/Kalkulati...', Resource id #181, NULL)
#3 C:\Projekte\np\library\ComposerPackages\vendor\sabre\event\lib\WildcardEmitterTrait.php(89): Sabre\DAV\CorePlugin->httpPut(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#4 C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\Server.php(472): Sabre\DAV\Server->emit('method:PUT', Array)
#5 C:\Projekte\np\library\ComposerPackages\vendor\sabre\dav\lib\DAV\Server.php(253): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#6 C:\Projekte\np\projekt\epm\filemanager\dav\Server.php(74): Sabre\DAV\Server->start()
#7 {main}</s:stacktrace>
</d:error>
Regards
The text was updated successfully, but these errors were encountered:
Hello,
Until now in our usage of sabre/dav the error only occurred in the function 'markDirty' from class Sabre\DAV\Tree and only when using php 8(8.0.10). Under php 7(7.4.21) it works fine.
The use of strpos in markDirty Sabre\DAV\Tree causes errors, because $nodePath can be an integer. This is because php casts all array keys to integers, whenever possible. So, if the key '1' gets set for $this->cache, it will become $this->cache[1] instead of $this->cache['1']. So, when the part of the path is only a number this error occurs.
The function reads this key and uses it in strpos. Because php 8 became more strict for types, it causes an error. We are using sabre/dav 4.1.5, but the error occurs in 4.1.1 as well.
The line "$nodePath = (string)$nodePath;" fixes this error.
Sabre/dav debug exception:
Regards
The text was updated successfully, but these errors were encountered: