Skip to content

Resolve intermittent issues finding templates in the phar#5962

Closed
johnpbloch wants to merge 1 commit intowp-cli:mainfrom
johnpbloch:main
Closed

Resolve intermittent issues finding templates in the phar#5962
johnpbloch wants to merge 1 commit intowp-cli:mainfrom
johnpbloch:main

Conversation

@johnpbloch
Copy link
Copy Markdown
Contributor

Fixes #5907

I left a comment on that issue diving deeper into what the root of the problem seems to be.

Basically, if the phar isn't named wp-cli.phar in the outer filesystem, then the phar itself won't be able to find things like templates in the inner filesystem when they're using __DIR__ as a reference point.

This has a companion change in wp-cli/wp-cli-bundle that will be coming shortly. That change will set the outer filesystem's filename in a constant inside boot-phar.php. This change checks for the presence of that constant before trying to use it, so there shouldn't be any issues affecting alternative installation/compilation strategies. If the constant exists, it looks for it as a full node in the phar-safe path and if found, replaces it with wp-cli.phar.

I noticed there weren't any tests for phar_safe_path(), so I started to write some, but with all the reliance on constants that was already there, it quickly became too difficult even to test the previous functionality, let alone the change. If someone could point me in the right direction of a way to run functional tests on a built phar, that may be an easier way to test this change.

@schlessera
Copy link
Copy Markdown
Member

From wp-cli/wp-cli-bundle#649:

I don't think this approach is ideal. It is still very hacky and it has issues with multibyte strings in filesystems.
I think this needs to be solved using php.net/manual/en/phar.running.php in the correct way. I'll have a stab at it...

@swissspidy
Copy link
Copy Markdown
Member

I believe this was ultimately fixed in wp-cli/wp-cli-bundle#752 for v2.12.0.

@swissspidy swissspidy closed this May 13, 2025
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.

wp theme status <theme-name> throws: Error: Couldn't find theme-status.mustache

3 participants