aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-26 16:59:18 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-26 16:59:18 +0200
commit7a44f66448fcdc53ed3c371c25317e553217eec8 (patch)
tree4dbd3ce3b487bb51768c84ea345a521dce215c29 /phpBB/phpbb
parent6aa8596d4dc206797e4740465e3035c65bcdba3f (diff)
downloadforums-7a44f66448fcdc53ed3c371c25317e553217eec8.tar
forums-7a44f66448fcdc53ed3c371c25317e553217eec8.tar.gz
forums-7a44f66448fcdc53ed3c371c25317e553217eec8.tar.bz2
forums-7a44f66448fcdc53ed3c371c25317e553217eec8.tar.xz
forums-7a44f66448fcdc53ed3c371c25317e553217eec8.zip
[ticket/12273] Use RecursiveDirectoryIterator in md_exporter
PHPBB3-12273
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/event/md_exporter.php32
1 files changed, 16 insertions, 16 deletions
diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php
index 540ec9a0d7..cb14ff5778 100644
--- a/phpBB/phpbb/event/md_exporter.php
+++ b/phpBB/phpbb/event/md_exporter.php
@@ -377,14 +377,21 @@ class md_exporter
* 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)
*/
- 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\recursive_dot_prefix_filter_iterator(
+ new \RecursiveDirectoryIterator(
+ $dir,
+ \FilesystemIterator::SKIP_DOTS
+ )
+ ),
+ \RecursiveIteratorIterator::SELF_FIRST
+ );
}
catch (\Exception $e)
{
@@ -394,24 +401,17 @@ class md_exporter
$files = array();
foreach ($iterator as $file_info)
{
- /** @var \DirectoryIterator $file_info */
- if ($file_info->isDot())
+ /** @var \RecursiveDirectoryIterator $file_info */
+ if ($file_info->isDir())
{
continue;
}
- // Do not scan some directories
- 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(), -5) == '.html')
+ $relative_path = $iterator->getInnerIterator()->getSubPathname();
+
+ if (substr($relative_path, -5) == '.html')
{
- $files[] = $file_info->getFilename();
+ $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
}
}