From: scribu Date: Tue, 12 Feb 2013 22:43:56 +0000 (+0200) Subject: use DirectoryIterator, since glob() doesn't work on Phar archives X-Git-Tag: v0.9.0~98^2~5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d824eeda952e79a7d4f49ad924f7072b8f01bf48;p=wvm%2Fwvm.git use DirectoryIterator, since glob() doesn't work on Phar archives --- diff --git a/php/WP_CLI/Dispatcher/RootCommand.php b/php/WP_CLI/Dispatcher/RootCommand.php index 989faa2c..654d4fca 100644 --- a/php/WP_CLI/Dispatcher/RootCommand.php +++ b/php/WP_CLI/Dispatcher/RootCommand.php @@ -108,13 +108,20 @@ EOB } protected function load_all_commands() { - foreach ( glob( WP_CLI_ROOT . "/commands/*.php" ) as $filename ) { - $command = str_replace( '.php', '', $filename ); + $cmd_dir = WP_CLI_ROOT . "commands"; + + $iterator = new \DirectoryIterator( $cmd_dir ); + + foreach ( $iterator as $filename ) { + if ( '.php' != substr( $filename, -4 ) ) + continue; + + $command = substr( $filename, 0, -4 ); if ( isset( $this->subcommands[ $command ] ) ) continue; - include $filename; + include "$cmd_dir/$filename"; } }