OSDN Git Service

Don't check if php://stdin is_file
authorgoldenapples <goldenapplesdesign@gmail.com>
Fri, 15 Feb 2013 20:59:13 +0000 (12:59 -0800)
committergoldenapples <goldenapplesdesign@gmail.com>
Fri, 15 Feb 2013 20:59:13 +0000 (12:59 -0800)
It'll let you down every time.

php/commands/post.php

index 7be856b..9073c4e 100644 (file)
@@ -16,10 +16,13 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
         */
        public function create( $args, $assoc_args ) {
                if ( ! empty( $args[0] ) ) {
-                       $readfile = ( $args[0] === '-' ) ? 'php://stdin' : $args[0];
 
-                       if ( ! file_exists( $readfile ) || ! is_file( $readfile ) )
-                                \WP_CLI::error( "Unable to read content from $readfile." );
+                       if ( $args[0] !== '-' ) {
+                               $readfile = $args[0];
+                               if ( ! file_exists( $readfile ) || ! is_file( $readfile ) )
+                                        \WP_CLI::error( "Unable to read content from $readfile." );
+                       } else
+                               $readfile = 'php://stdin';
 
                        $assoc_args['post_content'] = file_get_contents( $readfile );
                }