Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix template path for Phar installs #5918

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wojsmol
Copy link
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
@@ -602,7 +602,7 @@ function run_mysql_command( $cmd, $assoc_args, $_ = null, $send_to_shell = true,
*/
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
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
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
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.

None yet

3 participants