Skip to content

core download, --path option ignored #320

Closed

Description

@erwanlr

The --path option of the command wp core download is not taken into consideration during the copy of the files

https://github.com/wp-cli/wp-cli/blob/master/php/commands/core.php#L20

    $docroot = $assoc_args['path'];

https://github.com/wp-cli/wp-cli/blob/master/php/commands/core.php#L40

    WP_CLI::launch( 'cp -r wordpress/* . && rm -rf wordpress' );

Should be

    WP_CLI::launch( 'cp -r wordpress/* ' . $docroot . ' && rm -rf wordpress' );

Furthermore, if the $docroot does not exist, try to create it ;)

Activity

  1. scribu commented on Feb 25, 2013

    @scribu
    Member

    Nice catch. Care to transform it into a pull request, so that you show up on the contributors page? :)

  2. erwanlr commented on Feb 25, 2013

    @erwanlr
    ContributorAuthor

    Unfortunately, I do not have the time to switch to my dev machine to do so

  3. erwanlr commented on Feb 26, 2013

    @erwanlr
    ContributorAuthor

    Well, it's worse than expected :p

    The --path option is not even in the $assoc_args

    I've put a var_dump($assoc_args) to see it's content

    wp core download --path=wordpress351 --version=3.5.1
    array(1) {
      ["version"]=>
      string(5) "3.5.1"
    }
    

    So, there is something wrong somewhere else :p

  4. scribu commented on Feb 26, 2013

    @scribu
    Member

    --path is a global parameter, which is handled earlier:

    https://github.com/wp-cli/wp-cli/blob/master/php/WP_CLI/Runner.php#L225

    So, the correct fix would be to use ABSPATH, instead of checking $assoc_args['path'].

  5. erwanlr commented on Feb 26, 2013

    @erwanlr
    ContributorAuthor

    That leads to another issue :

    var_dump(ABSPATH);
    wp core download --path=wordpress351 --version=3.5.1
    string(13) "wordpress351/"
    
    wp core download  --version=3.5.1
    string(35) "/home/tests/wp-cli/test-core/"
    
  6. scribu commented on Feb 26, 2013

    @scribu
    Member

    Ok, so what's the issue?

  7. erwanlr commented on Feb 26, 2013

    @erwanlr
    ContributorAuthor

    w/o the --path option, ABSPATH is an absolute path - no problem with that

    however, with the option, it's a relative one

  8. scribu commented on Feb 26, 2013

    @scribu
    Member

    Yeah, I guess it should always be absolute, since that's why it's called ABSPATH. :)

    That's a bug in set_wp_root() then.

  9. erwanlr commented on Feb 26, 2013

    @erwanlr
    ContributorAuthor
    private static function set_wp_root( $config ) {
            if ( !empty( $config['path'] ) ) {
                define( 'ABSPATH', rtrim( $config['path'], '/' ) . '/' );
            } else {
                define( 'ABSPATH', getcwd() . '/' );
            }
        }

    Should be something like

    private static function set_wp_root( $config ) {
            $path = getcwd() . '/';
    
            if ( !empty( $config['path'] ) )
                $path .= rtrim( $config['path'], '/' ) . '/';
    
            define( 'ABSPATH', $path );
        }

    However, as there is not test for the Runner, I do not want to break something :D

  10. scribu commented on Feb 26, 2013

    @scribu
    Member

    Actually, we have functional tests run via Behat, but somehow they don't catch this issue:

    https://github.com/wp-cli/wp-cli/blob/master/features/bootstrap/FeatureContext.php#L176-186

  11. scribu commented on Feb 26, 2013

    @scribu
    Member

    Going to handle this in #327. Thanks for reporting, @erwanlr.

  12. erwanlr commented on Feb 26, 2013

    @erwanlr
    ContributorAuthor

    I'm currently fixing it :p

    Will send a pull request in a few minutes

  13. added 2 commits that reference this issue on Feb 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions