From 658db65cb477b790f217e0b8c6d202fbb1a8836c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 19 Nov 2011 22:04:43 +0100 Subject: [PATCH 1/2] [ticket/10323] make finder work with PHP 5.2 PHPBB3-10323 --- phpBB/includes/extension/finder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php index a1e6b2b347..11eb682f46 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/includes/extension/finder.php @@ -377,9 +377,14 @@ class phpbb_extension_finder } $directory_pattern = '#' . $directory_pattern . '#'; - $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file_info) { + if (in_array($file_info, array('.', '..'))) + { + continue; + } + if ($file_info->isDir() == $is_dir) { if ($is_dir) From 813b5344e6fa245f174692de71a4fb44f239786d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 20 Nov 2011 02:08:37 +0100 Subject: [PATCH 2/2] [ticket/10323] slight potential performance improvement PHPBB3-10323 --- phpBB/includes/extension/finder.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php index 11eb682f46..f4a0b7a371 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/includes/extension/finder.php @@ -380,7 +380,8 @@ class phpbb_extension_finder $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file_info) { - if (in_array($file_info, array('.', '..'))) + $filename = $file_info->getFilename(); + if ($filename == '.' || $filename == '..') { continue; } @@ -389,7 +390,7 @@ class phpbb_extension_finder { if ($is_dir) { - $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($file_info->getFilename()) . DIRECTORY_SEPARATOR; + $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; if ($relative_path[0] !== DIRECTORY_SEPARATOR) { $relative_path = DIRECTORY_SEPARATOR . $relative_path; @@ -399,10 +400,9 @@ class phpbb_extension_finder { $relative_path = DIRECTORY_SEPARATOR . $iterator->getInnerIterator()->getSubPathname(); } - $item_name = $file_info->getFilename(); if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && - (!$prefix || substr($item_name, 0, strlen($prefix)) === $prefix) && + (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && (!$directory || preg_match($directory_pattern, $relative_path))) { $files[str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1))] = $ext_name;