diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-05-24 18:58:52 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-05-24 18:58:52 +0200 |
commit | 930c5d85edc773bd21db85f9f811f55d727885e4 (patch) | |
tree | 4020ea36d503b776969721b551437c769056c967 | |
parent | f7896f46a5d93ce9119db71e75d77cc1af5bc139 (diff) | |
download | forums-930c5d85edc773bd21db85f9f811f55d727885e4.tar forums-930c5d85edc773bd21db85f9f811f55d727885e4.tar.gz forums-930c5d85edc773bd21db85f9f811f55d727885e4.tar.bz2 forums-930c5d85edc773bd21db85f9f811f55d727885e4.tar.xz forums-930c5d85edc773bd21db85f9f811f55d727885e4.zip |
[ticket/12589] Fix tests
PHPBB3-12589
-rw-r--r-- | phpBB/phpbb/extension/finder.php | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index 09c4f6d3e0..ff7bfad4ca 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -463,7 +463,10 @@ class finder } else if ($directory && $directory[0] === '/') { - $path .= substr($directory, 1); + if (!$is_dir) + { + $path .= substr($directory, 1); + } $directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); } else @@ -476,57 +479,56 @@ class finder } $directory_pattern = '#' . $directory_pattern . '#'; - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $path, - \FilesystemIterator::SKIP_DOTS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - - foreach ($iterator as $file_info) + if (is_dir($path)) { - $filename = $file_info->getFilename(); - - if ($file_info->isDir() == $is_dir) + $iterator = new \RecursiveIteratorIterator( + new \phpbb\recursive_dot_prefix_filter_iterator( + new \RecursiveDirectoryIterator( + $path, + \FilesystemIterator::SKIP_DOTS + ) + ), + \RecursiveIteratorIterator::SELF_FIRST + ); + + foreach ($iterator as $file_info) { - if ($is_dir) - { - $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; - if ($directory && $directory[0] === '/') - { - $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; - } - else if ($relative_path[0] !== DIRECTORY_SEPARATOR) - { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; - } - } - else + $filename = $file_info->getFilename(); + + if ($file_info->isDir() == $is_dir) { - $relative_path = DIRECTORY_SEPARATOR . $iterator->getInnerIterator()->getSubPathname(); - if ($directory && $directory[0] === '/') + if ($is_dir) { - $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; + $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; + if ($relative_path[0] !== DIRECTORY_SEPARATOR) + { + $relative_path = DIRECTORY_SEPARATOR . $relative_path; + } } else { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; + $relative_path = $iterator->getInnerIterator()->getSubPathname(); + if ($directory && $directory[0] === '/') + { + $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; + } + else + { + $relative_path = DIRECTORY_SEPARATOR . $relative_path; + } } - } - if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && - (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && - (!$directory || preg_match($directory_pattern, $relative_path))) - { - $files[] = array( - 'named_path' => str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)), - 'ext_name' => $ext_name, - 'path' => str_replace(array(DIRECTORY_SEPARATOR, $this->phpbb_root_path), array('/', ''), $file_info->getPath()) . '/', - 'filename' => $filename, - ); + if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && + (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && + (!$directory || preg_match($directory_pattern, $relative_path))) + { + $files[] = array( + 'named_path' => str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)), + 'ext_name' => $ext_name, + 'path' => str_replace(array(DIRECTORY_SEPARATOR, $this->phpbb_root_path), array('/', ''), $file_info->getPath()) . '/', + 'filename' => $filename, + ); + } } } } |