fix RecursiveDirectoryIterator() UnexpectedValueException thrown for PHP >= 5.3
@mattsches please test References #116 and http://board.s9y.org/viewtopic.php?f=1&t=19860
This commit is contained in:
parent
631bc150ac
commit
10d26f6fbf
@ -163,12 +163,8 @@ $dead_htmlarea_dirs = array(
|
|||||||
*/
|
*/
|
||||||
function recursive_directory_iterator($dir = array()) {
|
function recursive_directory_iterator($dir = array()) {
|
||||||
foreach ($dir AS $path) {
|
foreach ($dir AS $path) {
|
||||||
try {
|
serendipity_removeDeadFiles_SPL($path);
|
||||||
serendipity_removeDeadFiles_SPL($path);
|
@rmdir($path);
|
||||||
@rmdir($path);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo htmlspecialchars($path) . " >> File or directory probably does not exist.<br/>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +289,13 @@ function serendipity_killPlugin($name) {
|
|||||||
*/
|
*/
|
||||||
function serendipity_removeDeadFiles_SPL($dir=null, $deadfiles=null, $purgedir=null, $list_only=false) {
|
function serendipity_removeDeadFiles_SPL($dir=null, $deadfiles=null, $purgedir=null, $list_only=false) {
|
||||||
if (!is_dir($dir)) return;
|
if (!is_dir($dir)) return;
|
||||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
|
try {
|
||||||
|
$_dir = new RecursiveDirectoryIterator($dir);
|
||||||
|
// NOTE: UnexpectedValueException thrown for PHP >= 5.3
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$iterator = new RecursiveIteratorIterator($_dir, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
$search = array("\\", '//');
|
$search = array("\\", '//');
|
||||||
$replace = array('/');
|
$replace = array('/');
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user