Skip to content

Incorrect temp dir check on macOS #6

@swissspidy

Description

@swissspidy

I'm running macOS High Sierra (10.13) and PHP 7.2.6 (installed via Homebrew).

I noticed in wp-cli/language-command#38 that on macOS the following check always fails:

if ( 0 !== strpos( $dir, sys_get_temp_dir() ) ) {
throw new RuntimeException( sprintf( "Attempted to delete directory '%s' that is not in the temp directory '%s'. " . __FILE__ . ':' . __LINE__, $dir, sys_get_temp_dir() ) );
}

In my case, sys_get_temp_dir() points to /private/var/some-path-to-wp-cli.../.

$dir on the other hand points to /var/some-path-to-wp-cli.../. That's why I get an exception every time.

However, on macOS, /var is a symlink to /private/var though, so these paths are actually equal.

To solve this, realpath() needs to be used to resolve the symlinks before comparing the paths.

PR imminent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions