BTW, 1 minute ago I figured out that the same thing happens also when managing directories.
I created successfully a sub directory under some other directory but deleting was not possible because there I see again the double slashes like "pix//2005//02/test/ " (example from my existing local installation).
Again, some minutes (or hours?) of investigation took me to line ~1089:
Code: Select all
$files = array_merge($files, serendipity_traversePath($basedir, $dir . DIRECTORY_SEPARATOR . basename($file) . DIRECTORY_SEPARATOR, $onlyDirs, $pattern, ($depth+1)));
After that line I added a print_r($files) output to see what happens. Curious was that if the traversing has gone into depth it starts to add the second slash:
Code: Select all
[5] => Array
(
[name] => funpix
[depth] => 1
[relpath] => funpix/
)
[6] => Array
(
[name] => 2005
[depth] => 2
[relpath] => funpix/2005/
)
[7] => Array
(
[name] => 02
[depth] => 3
[relpath] => funpix//2005/02/
)
I though one slash is enough and changed the line to:
Code: Select all
$files = array_merge($files, serendipity_traversePath($basedir, $dir . basename($file) . DIRECTORY_SEPARATOR, $onlyDirs, $pattern, ($depth+1)));
And for now the display is correct:
Code: Select all
[5] => Array
(
[name] => funpix
[depth] => 1
[relpath] => funpix/
)
[6] => Array
(
[name] => 2005
[depth] => 2
[relpath] => funpix/2005/
)
[7] => Array
(
[name] => 02
[depth] => 3
[relpath] => funpix/2005/02/
)
And, last but not least get rid of the trailing slash at line 1084:
Code: Select all
'relpath' => str_replace(DIRECTORY_SEPARATOR, '/', ltrim($dir, DIRECTORY_SEPARATOR) . basename($file) )
The wished result:
Code: Select all
[3] => Array
(
[name] => funpix
[depth] => 1
[relpath] => funpix
)
[4] => Array
(
[name] => 2005
[depth] => 2
[relpath] => funpix/2005
)
[5] => Array
(
[name] => 02
[depth] => 3
[relpath] => funpix/2005/02
)
That is needed that the rmdir works properly.
Now because basically it does not work right now I investigated the code a bit more and found out that there's a problem.
You open the directory $directory in function serendipity_killPath but you do not close it before you try to delete the directory. That's causing a "Permission denied" error because of the open handle.
Solution for this is easy.
Code: Select all
...
} // <-- Add this here to close the very first if, linenr. ~1053
closedir($handle); // <-- needed for closing the handle
echo '<strong>';
if ($serious && !empty($directory) && !preg_match('@^.?/?$@', $directory) && @rmdir($basedir . $directory)) {
printf(DIRECTORY_DELETE_SUCCESS . $n, $directory);
} else {
printf(DIRECTORY_DELETE_FAILED . $n, $directory);
}
echo '</strong>';
// } <-- original end of the first if
...
That's all. I hope the desciption is useful. The directory handling works now (at least for me) with those fixes.
Regards, Thomas