mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-26 20:08:55 +00:00
[ticket/12268] Extension finder should not crawl through .git/ of extensions
This new filter ignores .svn and .git directories. When searching for php classes and template files of extensions we don't need to look inside these directories. PHPBB3-12268
This commit is contained in:
parent
8a61e4b4c0
commit
a3b95839f5
2 changed files with 34 additions and 1 deletions
|
@ -475,7 +475,8 @@ class finder
|
||||||
}
|
}
|
||||||
$directory_pattern = '#' . $directory_pattern . '#';
|
$directory_pattern = '#' . $directory_pattern . '#';
|
||||||
|
|
||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new \phpbb\extension\recursive_filter_iterator(new \RecursiveDirectoryIterator($path));
|
||||||
|
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($iterator as $file_info)
|
foreach ($iterator as $file_info)
|
||||||
{
|
{
|
||||||
$filename = $file_info->getFilename();
|
$filename = $file_info->getFilename();
|
||||||
|
|
32
phpBB/phpbb/extension/recursive_filter_iterator.php
Normal file
32
phpBB/phpbb/extension/recursive_filter_iterator.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package extension
|
||||||
|
* @copyright (c) 2014 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class recursive_filter_iterator
|
||||||
|
*
|
||||||
|
* This Filter ignores .svn and .git directories.
|
||||||
|
* When searching for php classes and template files of extensions
|
||||||
|
* we don't need to look inside these directories.
|
||||||
|
*
|
||||||
|
* @package phpbb\extension
|
||||||
|
*/
|
||||||
|
class recursive_filter_iterator extends \RecursiveFilterIterator
|
||||||
|
{
|
||||||
|
public static $ignore_folders = array(
|
||||||
|
'.svn',
|
||||||
|
'.git',
|
||||||
|
);
|
||||||
|
|
||||||
|
public function accept()
|
||||||
|
{
|
||||||
|
return !in_array($this->current()->getFilename(), self::$ignore_folders);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue