Skip to content

Fix template path for Phar installs#5918

Closed
wojsmol wants to merge 1 commit intowp-cli:mainfrom
wojsmol:fix/phar-template-path
Closed

Fix template path for Phar installs#5918
wojsmol wants to merge 1 commit intowp-cli:mainfrom
wojsmol:fix/phar-template-path

Conversation

@wojsmol
Copy link
Copy Markdown
Contributor

@wojsmol wojsmol commented Mar 15, 2024

Related #4689

Fixes paths used for accessing the Mustache template files within the Phar file will need to be wrapped in Utils\phar_safe_path().

@wojsmol wojsmol requested a review from a team as a code owner March 15, 2024 15:06
@danielbachhuber danielbachhuber changed the title fix template path in phar installs Fix template path for Phar installs Mar 21, 2024
function mustache_render( $template_name, $data = [] ) {
if ( ! file_exists( $template_name ) ) {
$template_name = WP_CLI_ROOT . "/templates/$template_name";
$template_name = phar_safe_path( WP_CLI_ROOT . "/templates/$template_name" );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test for this? Also, can we document the nature of the change in the PR description?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielbachhuber PR description updated. I don't know how to write test for this change.

@danielbachhuber danielbachhuber self-requested a review April 26, 2024 13:12
Copy link
Copy Markdown
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wojsmol Were you able to reproduce the original issue and confirm that this fixes it?

I'm a little unclear that this is the actual solution. In reviewing #4689 (comment), wp config create is already passing a Phar-safe path:

https://github.com/wp-cli/config-command/blob/445dfd0276a8e717ed4d2dd6f9dd0b769097fba4/src/Config_Command.php#L278-L279

As such, the file_exists() check should return true and this particular block of code shouldn't be executed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants