Skip to content

Use Utils\make_temp_file() for temporary paths #345

Description

@schlessera

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

  • src/Core_Command.php:301: Utils\get_temp_dir() . uniqid( 'wp_' ) . '.tmp'
  • src/Core_Command.php:2245: Utils\get_temp_dir() . uniqid( 'wp_' ) . '.zip'
  • src/WP_CLI/Core/CoreUpgrader.php:87: Utils\get_temp_dir() . uniqid( 'wp_' ) . ".{$extension}"

Switch them to Utils\make_temp_file( 'wp_', '.tmp' ), Utils\make_temp_file( 'wp_', '.zip' ) and Utils\make_temp_file( 'wp_', ".{$extension}" ). The helper creates the file up front with mode 0600 and errors out instead of handing back a path that might already exist. The shutdown-function cleanup at each site stays as it is.

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

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions