From 51a47068e12a9496f3714f4ef0854aef904085b5 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 5 Mar 2019 18:04:52 +0100 Subject: [PATCH] Switch to a recursive directory iterator for the file fetcher. --- inc/classes/iterator/files/class-base.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inc/classes/iterator/files/class-base.php b/inc/classes/iterator/files/class-base.php index eaa552f..ede1ed2 100644 --- a/inc/classes/iterator/files/class-base.php +++ b/inc/classes/iterator/files/class-base.php @@ -88,13 +88,14 @@ protected function get_files_in_path() { } if ( is_dir( $path_found ) ) { + $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path_found ) ); + $files = []; - $files = array_map( function( $item ) use ( $path_found ) { - - return $path_found . '/' . $item; - - }, scandir( $path_found ) ); - + foreach ( $iterator as $pointer ) { + if ( ! $pointer->isDir() ) { + $files[] = $pointer->getPathname(); + } + } } else { $files = [ $path_found ];