mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-09 00:55:23 +02:00
[feature/extension-manager] Correctly detect and handle directories in finder
PHPBB3-10323
This commit is contained in:
parent
77f42969ab
commit
fbc2442ccd
@ -326,22 +326,30 @@ class phpbb_extension_finder
|
|||||||
}
|
}
|
||||||
$directory_pattern = '#' . $directory_pattern . '#';
|
$directory_pattern = '#' . $directory_pattern . '#';
|
||||||
|
|
||||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($iterator as $file_info)
|
foreach ($iterator as $file_info)
|
||||||
{
|
{
|
||||||
if ($file_info->isDir() == $is_dir)
|
if ($file_info->isDir() == $is_dir)
|
||||||
{
|
{
|
||||||
$relative_path = ($is_dir) ? $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR:
|
if ($is_dir)
|
||||||
$iterator->getInnerIterator()->getSubPathname();
|
{
|
||||||
|
$relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($file_info->getFilename()) . DIRECTORY_SEPARATOR;
|
||||||
$item_name = ($is_dir) ? basename($iterator->getInnerIterator()->getSubPath()) :
|
if ($relative_path[0] !== DIRECTORY_SEPARATOR)
|
||||||
$file_info->getFilename();
|
{
|
||||||
|
$relative_path = DIRECTORY_SEPARATOR . $relative_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$relative_path = DIRECTORY_SEPARATOR . $iterator->getInnerIterator()->getSubPathname();
|
||||||
|
}
|
||||||
|
$item_name = $file_info->getFilename();
|
||||||
|
|
||||||
if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) &&
|
if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) &&
|
||||||
(!$prefix || substr($item_name, 0, strlen($prefix)) === $prefix) &&
|
(!$prefix || substr($item_name, 0, strlen($prefix)) === $prefix) &&
|
||||||
(!$directory || preg_match($directory_pattern, DIRECTORY_SEPARATOR . $relative_path)))
|
(!$directory || preg_match($directory_pattern, $relative_path)))
|
||||||
{
|
{
|
||||||
$files[] = str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . $relative_path);
|
$files[] = str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user