diff options
author | Dhruv <dhruv.goel92@gmail.com> | 2014-03-23 02:39:00 +0530 |
---|---|---|
committer | Dhruv <dhruv.goel92@gmail.com> | 2014-03-23 02:39:00 +0530 |
commit | dfa1377f1b3699473cb887c6531e6a59d69b2199 (patch) | |
tree | 982fcad3b7328019dfd26c07440dc05aafa09a7b /phpBB | |
parent | 84b91beed1927aebf3a3b93d04eb6b5ec627097e (diff) | |
parent | 584d7b5823e8c959e921dc5b154bf535182fc32d (diff) | |
download | forums-dfa1377f1b3699473cb887c6531e6a59d69b2199.tar forums-dfa1377f1b3699473cb887c6531e6a59d69b2199.tar.gz forums-dfa1377f1b3699473cb887c6531e6a59d69b2199.tar.bz2 forums-dfa1377f1b3699473cb887c6531e6a59d69b2199.tar.xz forums-dfa1377f1b3699473cb887c6531e6a59d69b2199.zip |
Merge remote-tracking branch 'nickvergessen/ticket/12268' into develop-ascraeus
# By Joas Schilling
# Via Joas Schilling
* nickvergessen/ticket/12268:
[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
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/extension/finder.php | 15 | ||||
-rw-r--r-- | phpBB/phpbb/recursive_dot_prefix_filter_iterator.php | 28 |
2 files changed, 38 insertions, 5 deletions
diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index c9c16ae6d5..6cc6e1808a 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -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) { diff --git a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php new file mode 100644 index 0000000000..6ef63ec906 --- /dev/null +++ b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php @@ -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] !== '.'; + } +} |