Skip to content

Use Utils\make_temp_file() and Utils\make_temp_dir() for temporary paths #249

Description

@schlessera

wp-cli/wp-cli#6374 added Utils\make_temp_file() and Utils\make_temp_dir() (merged to main, milestone 3.0.0). src/Package_Command.php still builds temporary paths by hand:

  • line 279: Utils\get_temp_dir() . uniqid( 'wp-cli-package_', true ) . '.zip' for the downloaded ZIP
  • line 294: Utils\get_temp_dir() . uniqid( 'wp-cli-package_', true ) for the extraction directory

Switch them to Utils\make_temp_file( 'wp-cli-package_', '.zip' ) and Utils\make_temp_dir( 'wp-cli-package_' ). Two things to check on the way: make_temp_dir() creates the directory (mode 0700) before Extractor::extract() runs, so the extractor gets an existing empty directory instead of creating it, and it returns the path with a trailing slash, which the later get_package_name_and_version_from_dir_package(), copy_overwrite_files() and rmdir() calls receive.

Blocked on a wp-cli/wp-cli release that ships the helpers. composer.json already requires wp-cli/wp-cli ^3.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions