OSDN Git Service

Fixes Runner::set_wp_root to handle absolute & relative path
authorerwanlr <erwan.lr@gmail.com>
Tue, 26 Feb 2013 21:55:40 +0000 (22:55 +0100)
committererwanlr <erwan.lr@gmail.com>
Tue, 26 Feb 2013 21:55:40 +0000 (22:55 +0100)
php/WP_CLI/Runner.php

index 433507c..ff9ecb2 100644 (file)
@@ -82,11 +82,20 @@ class Runner {
        }
 
        private static function set_wp_root( $config ) {
-               if ( !empty( $config['path'] ) ) {
-                       define( 'ABSPATH', rtrim( $config['path'], '/' ) . '/' );
-               } else {
-                       define( 'ABSPATH', getcwd() . '/' );
+               $path = getcwd();
+
+               if ( !empty( $config['path'] ) )
+               {
+                       if ( self::is_absolute_path( $config['path'] ) )
+                               $path = $config['path'];
+                       else
+                               $path .= $config['path'];
                }
+               define( 'ABSPATH', rtrim( $path, '/' ) . '/' );
+       }
+
+       private static function is_absolute_path( $path ) {
+               return $path[0] === '/' ? true : false;
        }
 
        private static function set_url( $assoc_args ) {