fix(php-update): detect all PHP versions, prevent duplicate state entries, fix --version flag - #225
Merged
Merged
Conversation
…ries, fix --version flag Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/5fd6e355-c679-4f8a-8261-b556b41c4a36 Co-authored-by: PDowney <11467177+PDowney@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix PHP version detection to identify all installed versions
fix(php-update): detect all PHP versions, prevent duplicate state entries, fix --version flag
May 2, 2026
Removed outdated entry for PHP update from CHANGELOG.
PDowney
approved these changes
May 2, 2026
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes correctness issues in the PHP upgrade automation script (scripts/update/php-update.sh) to better handle multi-version installations, make state-file writes idempotent, and correct a CLI flag.
Changes:
- Collects all installed non-target PHP-FPM versions during auto-detection (instead of stopping at the first match).
- Avoids appending duplicate
PHP=1entries in/etc/enginescript/install-state.confby updating in-place when present. - Fixes PHP CLI version output command to use
php --version.
Comment on lines
+38
to
42
| OLD_PHP_VERS=() | ||
| for ver in "${SUPPORTED_PHP_VERSIONS[@]}"; do | ||
| if [[ "${ver}" != "${NEW_PHP_VER}" ]] && dpkg -l | grep -q "php${ver}-fpm"; then | ||
| OLD_PHP_VER="${ver}" | ||
| break | ||
| OLD_PHP_VERS+=("${ver}") | ||
| fi |
Comment on lines
+170
to
+173
| if grep -q '^PHP=' /etc/enginescript/install-state.conf; then | ||
| sed -i 's/^PHP=.*/PHP=1/' /etc/enginescript/install-state.conf | ||
| else | ||
| echo "PHP=1" >> /etc/enginescript/install-state.conf |
Comment on lines
+67
to
+68
| echo "Detected PHP installation(s): ${OLD_PHP_VERS[*]}" | ||
| echo "Proceeding with upgrade to PHP ${NEW_PHP_VER} (primary source version: ${OLD_PHP_VER})..." |
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.



Three correctness bugs in
scripts/update/php-update.sh— orphaned PHP installs on multi-version systems, duplicateinstall-state.confentries on re-runs, and a broken CLI flag.Software Version Updates
Changed Versions
scripts/update/php-update.sh— logic fixes (no version bump)Version Diff
Verification Checklist
Notes
OLD_PHP_VERS[];OLD_PHP_VERis set to the first element so downstream removal logic is unchanged. Prevents orphaned installs when e.g. both 8.2 and 8.3 are present.PHP=line ininstall-state.confis updated in-place viasedif it already exists, avoiding duplicate entries on repeated runs.php -version(unknown flag, exits non-zero) corrected tophp --version.Original prompt