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

WP_CLI_PHP ignored even when installing from deb not phar #5886

Open
sshankar-rks opened this issue Dec 8, 2023 · 5 comments
Open

WP_CLI_PHP ignored even when installing from deb not phar #5886

sshankar-rks opened this issue Dec 8, 2023 · 5 comments

Comments

@sshankar-rks
Copy link

Bug Report

--- ✅ If you are in the correct location now... --->

Describe the current, buggy behavior

wp-cli installed from here
Ubuntu 22.04
PHP is PHP-FPM 8.1 (/usr/sbin/php-fpm8.1)
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
WP_CLI_PHP="/usr/sbin/php-fpm8.1"

wp cli info shows the PHP used is php from /usr/bin, not WP_CLI_PHP as expected

Documentation says:
"WP_CLI_PHP – PHP binary path to use when overriding the system default (only works for non-Phar installation)."
Used to work with 2.5.0 deb file

Workaround
I tried this workaround.
But since /usr/local/wp is actually a script, not a php file, that workaround fails.

What I did:
Created a symbolic link from /usr/sbin/php-fpm8.1 to /usr/sbin/php
Then changed system path
PATH="/usr/sbin:$PATH"

That isn't a change I want to do. That changes the entire system's PHP version .

(Paste the output of "wp cli info" into this box)

OS:     Linux 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 x86_64
Shell:
PHP binary:     /usr/bin/php8.1
PHP version:    8.1.2-1ubuntu2.14
php.ini used:   /etc/php/8.1/cli/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 8.0.35-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /
WP-CLI packages dir:
WP-CLI cache dir:       /root/.wp-cli/cache
WP-CLI global config:   /home/wordpress/wp-cli.local.yml
WP-CLI project config:
WP-CLI version: 2.9.0

Expected behavior
The WP_CLI_PHP variable (and it's sibling, WP_CLI_PHP_ARGS) should both work whether using phar install or not.

@danielbachhuber
Copy link
Member

Thanks for the report, @sshankar-rks.

I'm not an expert in the debian build but, AFAIK, it's just bundling the Phar file:

https://github.com/wp-cli/wp-cli-bundle/blob/8094b100cca467fe32a58e02a7ffe43ce26061b8/utils/wp-cli-updatedeb.sh#L45-L49

I don't think there have been any substantial changes between 2.5.0 and 2.9.0:

https://github.com/wp-cli/wp-cli-bundle/commits/8094b100cca467fe32a58e02a7ffe43ce26061b8/utils/wp-cli-updatedeb.sh

Can you re-test with the 2.5.0 binary?

@sshankar-rks
Copy link
Author

I used the 2.5.0 binary for a couple of years now and wp cli info now shows changed locations for both executable and ini file.

Here is the output from the older version:
OS: Linux 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
Shell:
PHP binary: /usr/sbin/php-fpm7.4
PHP version: 7.4.3-4ubuntu2.19
php.ini used: /usr/bin/php-cli.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.35-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/lib/www
WP-CLI packages dir:
WP-CLI global config: /home/wordpress/wp-cli.local.yml
WP-CLI project config:
WP-CLI version: 2.5.0

I think the issue is that there is no supported way to change the PHP version in the current and future versions of WP-CLI.

@wojsmol
Copy link
Contributor

wojsmol commented Dec 9, 2023

@danielbachhuber @sshankar-rks IMHO #5672 can be a root cause of this issue.

@danielbachhuber
Copy link
Member

@wojsmol So, stated another way:

  1. The reported PHP binary was incorrect with php-wpcli_2.5.0_all.deb
  2. The reported PHP binary became correct when Always return PHP_BINARY when using a PHAR bundle #5672 was applied.
  3. The deb file has never supported WP_CLI_PHP.

Are these three statements correct?

If they are, I think we can update the deb file to support WP_CLI_PHP. However, I think we'll need to wait until 3.0.0 because it would technically be a breaking change.

@sshankar-rks
Copy link
Author

For a complete fix, WP_CLI_PHP_ARGS also needs to be supported in the deb file.
And the php.ini file used must be the one seen in wp-cli's output.

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

No branches or pull requests

3 participants