mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-21 18:58:53 +00:00
Merge branch 'develop-ascraeus' into develop
# By Joas Schilling # Via Dhruv (1) and Joas Schilling (1) * develop-ascraeus: [ticket/12268] Do not use substr but just compare the character [ticket/12268] Rename class file to recursive_dot_prefix_filter_iterator.php [ticket/12268] Move class out of extension namespace and rename it [ticket/12268] Do not search in folders starting with a dot [ticket/12268] Use FilesystemIterator::SKIP_DOTS [ticket/12268] Extension finder should not crawl through .git/ of extensions
This commit is contained in:
commit
f7718f8647
2 changed files with 38 additions and 5 deletions
|
@ -475,14 +475,19 @@ class finder
|
|||
}
|
||||
$directory_pattern = '#' . $directory_pattern . '#';
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
$path,
|
||||
\FilesystemIterator::SKIP_DOTS
|
||||
)
|
||||
),
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
$filename = $file_info->getFilename();
|
||||
if ($filename == '.' || $filename == '..')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($file_info->isDir() == $is_dir)
|
||||
{
|
||||
|
|
28
phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
Normal file
28
phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package extension
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb;
|
||||
|
||||
/**
|
||||
* Class recursive_dot_prefix_filter_iterator
|
||||
*
|
||||
* This filter ignores directories starting with a dot.
|
||||
* When searching for php classes and template files of extensions
|
||||
* we don't need to look inside these directories.
|
||||
*
|
||||
* @package phpbb
|
||||
*/
|
||||
class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator
|
||||
{
|
||||
public function accept()
|
||||
{
|
||||
$filename = $this->current()->getFilename();
|
||||
return !$this->current()->isDir() || $filename[0] !== '.';
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue