Repository navigation
fix(php): stop the install when the PHP CLI disables functions ee needs - #49
Merged
Merged
Conversation
HestiaCP and similar panels put pcntl_signal, pcntl_signal_dispatch and other functions into disable_functions of the CLI php.ini. PHP 8 removes disabled functions, so the install succeeded and the first `ee site` command died with "Call to undefined function EE\Site\Type\pcntl_signal()". check_php_functions asks the host PHP CLI whether the functions ee calls are available and stops before Docker and the phar are installed, naming the functions, the ini files that disable them and a conf.d override that survives panel upgrades. On PHP 7, where calling a disabled function only warns, disabled pcntl_* functions only get a warning. Refs EasyEngine/easyengine#1956
Bats cases for the report parsing, the messages, PHP 7's warn-only pcntl case and the check's place in check_dependencies, plus real-PHP cases when php is installed. Host prep now asserts on every matrix distro that the stock PHP passes and that a HestiaCP-style disable_functions file in the CLI scan dir is refused with the functions and the file named.
The error no longer assumes a hosting panel set disable_functions. It names the functions and ini files, says why EasyEngine needs them, and suggests a conf.d override that a tool rewriting php.ini on upgrade leaves alone, or editing php.ini directly. When a conf.d file itself disables them, the override would not win, so it asks to edit the listed files instead. Continuation lines use ee_log_verbose instead of hand-typed indentation.
Drop the line repeating that EasyEngine needs the functions and fold the conf.d override and the php.ini alternative into one line, so every variant of the disabled-functions error is at most 4 lines. The missing-functions error uses the same "To fix it" wording. Tests assert the line counts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the host's PHP CLI disables functions that
eecalls, the installer still finishes successfully, and the firstee site …command dies. EasyEngine/easyengine#1956 is a HestiaCP server on Ubuntu 24.04: the installer kept the existing PHP 8.3,ee cli inforan fine, andee site createfailed with:Root cause
HestiaCP writes
disable_functions = pcntl_alarm,pcntl_fork,…,pcntl_signal,pcntl_signal_dispatch,…into/etc/php/<version>/cli/php.ini(bin/v-add-web-php,install/upgrade/versions/1.8.12.sh). Since PHP 8, a disabled function is removed from the function table, so calling it is a fatal "undefined function" error.EE_Site_Command::__construct()callspcntl_signal()for every site command.ee cli infonever builds a site object, so the installer's first run doesn't hit it.The installer keeps any existing
phpand only checks the curl, sqlite3 and zip extensions. pcntl is loaded on such hosts; only its functions are disabled.Fix
A new
check_php_functionsstep incheck_dependencies. It runs after PHP and its extensions are set up, and Docker setup now runs after it, so a refused host doesn't get Docker installed first. The step asks the host PHP CLI whether the functionseecalls unguarded exist, the ones hardened php.ini files tend to list:curl_exec,disk_free_space,escapeshellarg,exec,getmypid,ini_set,pcntl_signal,pcntl_signal_dispatch,php_uname,posix_getegid,posix_geteuid,posix_getpwuid,proc_close,proc_open. If any are unavailable, the install stops before anything else is installed:function_exists()is false, so nothing PHP itself still allows is reported. PHP matchesdisable_functionsnames case-sensitively and splits the list on commas and whitespace. Thedisable_functionslist is only used to word the message ("disables" vs "lacks") and to name the ini files that set it.pcntl_*functions there, the step prints a warning (no rollback on signals) and doesn't stop the install.conf.dfile itself setsdisable_functions, an override there might not load last, so the message asks to edit the listed files instead.How tested
Repro recipe: a throwaway
ubuntu:24.04amd64 container, like the reporter'snoblehost.php8.3-clifrom ppa:ondrej/php.v-add-web-phpline to the CLI php.ini.setup.shwith the real phar andee.ee site create site.test --type=wp --cachemaster(byte-identical to what https://rt.cx/ee4 serves)Call to undefined function EE\Site\Type\pcntl_signal(), rc 255 (same foree site list)master, same recipe without the Hestia line (control)conf.d/99-easyengine.iniubuntu:22.04,24.04,26.04,rolling,devel,debian:12and13all return rc 0, the check passes, andsite creategets past the constructor. Host prep passes on the same 7 images.php:7.4-cli): disabledpcntl_signalonly warns (rc 0), and disabledexecstops the install.Tests:
tests/unit/php_functions.bats:php, including the PHP 7 warning, and that each error is at most 4 lines.check_dependenciesruns the check after PHP setup and before Docker.phpis installed.tests/integration/host-prep.sh: on every matrix distro, the stock PHP passes the check, and a HestiaCP-styledisable_functionsfile in the CLI scan dir is refused with the functions and the file named, and the message asks to edit that file in at most 4 lines.Refs EasyEngine/easyengine#1956