aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/event/php_exporter.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-26 18:04:47 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-26 18:04:47 +0200
commit927c219b1fc1cc69f724827771d567384b2cda8c (patch)
tree7c3cb3c2f37d0f144acc0a4d21e41d9cc124e4f1 /phpBB/phpbb/event/php_exporter.php
parent7a44f66448fcdc53ed3c371c25317e553217eec8 (diff)
downloadforums-927c219b1fc1cc69f724827771d567384b2cda8c.tar
forums-927c219b1fc1cc69f724827771d567384b2cda8c.tar.gz
forums-927c219b1fc1cc69f724827771d567384b2cda8c.tar.bz2
forums-927c219b1fc1cc69f724827771d567384b2cda8c.tar.xz
forums-927c219b1fc1cc69f724827771d567384b2cda8c.zip
[ticket/12273] Use RecursiveDirectoryIterator with filter in php_exporter
PHPBB3-12273
Diffstat (limited to 'phpBB/phpbb/event/php_exporter.php')
-rw-r--r--phpBB/phpbb/event/php_exporter.php56
1 files changed, 14 insertions, 42 deletions
diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php
index 41058216e8..8e4a9d399d 100644
--- a/phpBB/phpbb/event/php_exporter.php
+++ b/phpBB/phpbb/event/php_exporter.php
@@ -100,17 +100,22 @@ class php_exporter
/**
* Returns a list of files in $dir
*
- * Works recursive with any depth
- *
* @param string $dir Directory to go through
- * @param string $path Path from root to $dir
- * @return array List of files (including directories)
+ * @return array List of files (including the path)
*/
- public function get_recursive_file_list($dir, $path = '')
+ public function get_recursive_file_list($dir)
{
try
{
- $iterator = new \DirectoryIterator($dir);
+ $iterator = new \RecursiveIteratorIterator(
+ new \phpbb\event\recursive_event_filter_iterator(
+ new \RecursiveDirectoryIterator(
+ $dir,
+ \FilesystemIterator::SKIP_DOTS
+ )
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
}
catch (\Exception $e)
{
@@ -120,42 +125,9 @@ class php_exporter
$files = array();
foreach ($iterator as $file_info)
{
- /** @var \DirectoryIterator $file_info */
- if ($file_info->isDot())
- {
- continue;
- }
-
- // Do not scan some directories
- if ($file_info->isDir() && (
- ($path == '' && in_array($file_info->getFilename(), array(
- 'cache',
- 'develop',
- 'ext',
- 'files',
- 'language',
- 'store',
- 'vendor',
- )))
- || ($path == '/includes' && in_array($file_info->getFilename(), array('utf')))
- || ($path == '/phpbb/db/migration' && in_array($file_info->getFilename(), array('data')))
- || ($path == '/phpbb' && in_array($file_info->getFilename(), array('event')))
- ))
- {
- continue;
- }
- else if ($file_info->isDir())
- {
- $sub_dir = $this->get_recursive_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename());
- foreach ($sub_dir as $file)
- {
- $files[] = $file_info->getFilename() . '/' . $file;
- }
- }
- else if (substr($file_info->getFilename(), -4) == '.php')
- {
- $files[] = $file_info->getFilename();
- }
+ /** @var \RecursiveDirectoryIterator $file_info */
+ $relative_path = $iterator->getInnerIterator()->getSubPathname();
+ $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
}
return $files;