Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

CLI PHP version is not the same as the web PHP version #264

Open
JPry opened this issue Jul 14, 2022 · 2 comments
Open

CLI PHP version is not the same as the web PHP version #264

JPry opened this issue Jul 14, 2022 · 2 comments
Labels

Comments

@JPry
Copy link
Contributor

JPry commented Jul 14, 2022

I recently spun up a JN site, and specified PHP 8.0. The site itself was configured correctly, but when I went to run commands using WP CLI, I discovered that the version of PHP being used for the command line interface is the default, currently PHP 7.4. This causes an PHP 8 features to trigger a fatal error when CLI is executed for the site.

Here is the output from wp --info on CLI:

wp --info
OS:	Linux 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
Shell:	/bin/bash
PHP binary:	/opt/sp/php7.4/bin/php
PHP version:	7.4.30
php.ini used:	/etc/php7.4-sp/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using  EditLine wrapper
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:	/srv/users/user95535f5e/apps/user95535f5e/public
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.6.0

Doing some digging, I see that /usr/bin/wp is a simple wrapper to call the wp-cli.phar file:

#!/bin/bash

export PATH=/opt/sp/php7.4/bin:$PATH
php /opt/sp/bin/wp-cli.phar "$@"

With this in mind, setting up the site should include mapping /usr/bin/wp to use the correct version of PHP based on the site options. It might be beneficial to also change the native PHP being called, but using WP CLI will likely be the more prevalent use case.

As a workaround, I found that the PHP 8 executable is available (along with other version), but it needs to be specified manually to work properly with WP CLI:

php8.0-sp /opt/sp/bin/wp-cli.phar --info
OS:	Linux 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
Shell:	/bin/bash
PHP binary:	/opt/sp/php8.0/bin/php
PHP version:	8.0.20
php.ini used:	/etc/php8.0-sp/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using  EditLine wrapper
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:	/srv/users/user95535f5e/apps/user95535f5e/public
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.6.0

Steps to reproduce

  1. Spin up a new site with Jurassic Ninja, specifying PHP 8 as the version
  2. Visit Dashboard > Tools > Site Health > Info. Look under the "Server" section to see the version of PHP being used
  3. From the command line, run wp --info or php --version to see that a different version of PHP is being used.
@JPry JPry added the bug label Jul 14, 2022
@waclawjacek
Copy link
Contributor

The CLI version is controlled on the server and is not something the JN site controls. Unless you mean the Docker image defaults? In this case this is something that should be fixed. :)

@JPry
Copy link
Contributor Author

JPry commented Sep 3, 2024

@waclawjacek

Unless you mean the Docker image defaults?

No, for the actual Jurassic.ninja service.

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

No branches or pull requests

2 participants