fix(php-update): remove redundant duplicate tracking and narrow over-broad sed regexes - #229
Merged
Merged
Conversation
…sed regexes Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/133853f7-5ec5-4cc2-af9f-1655e0e14c14 Co-authored-by: PDowney <11467177+PDowney@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove redundant SEEN_OLD_PHP_VERS in PHP update script
fix(php-update): remove redundant duplicate tracking and narrow over-broad sed regexes
May 2, 2026
Removed redundant PHP version tracking and improved regex replacements for configuration files to prevent unintended changes.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
PDowney
approved these changes
May 2, 2026
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the PHP upgrade script so version rewrites during PHP migrations are more narrowly scoped, aiming to reduce accidental edits to unrelated text in deployed config files while simplifying old-version detection.
Changes:
- Removes redundant duplicate tracking when collecting installed legacy PHP-FPM versions.
- Replaces broad global
sedsubstitutions with more targeted patterns for Nginx, phpSysInfo, and admin control panel files. - Limits some replacements to specific directive/context lines instead of the entire file.
Comment on lines
+135
to
+137
| sed -E -i \ | ||
| -e "s|(unix:/run/php/)php${OLD_VER}-fpm(\.sock)|\1php${NEW_PHP_VER}-fpm\2|g" \ | ||
| -e "s|(fastcgi_pass[[:space:]]+[^;]*php)${OLD_VER}(-fpm)|\1${NEW_PHP_VER}\2|g" \ |
| if [[ -f "$config_file" ]]; then | ||
| for OLD_VER in "${MIGRATION_SOURCE_PHP_VERS[@]}"; do | ||
| sed -E -i "s|php${OLD_VER}(-fpm)?|php${NEW_PHP_VER}\1|g" "$config_file" | ||
| sed -E -i "/^[[:space:]]*fastcgi_pass[[:space:]]+/ s|php${OLD_VER}(-fpm)?|php${NEW_PHP_VER}\1|g" "$config_file" |
| echo "Updating phpSysInfo configuration..." | ||
| for OLD_VER in "${MIGRATION_SOURCE_PHP_VERS[@]}"; do | ||
| sed -E -i "s|php${OLD_VER}(-fpm)?|php${NEW_PHP_VER}\1|g" "/var/www/admin/tools/phpsysinfo/phpsysinfo.ini" | ||
| sed -E -i "s|^([[:space:]]*[[:alnum:]_.-]+[[:space:]]*=[[:space:]]*.*)php${OLD_VER}(-fpm)?|\1php${NEW_PHP_VER}\2|g" "/var/www/admin/tools/phpsysinfo/phpsysinfo.ini" |
| echo "Updating admin control panel API configuration..." | ||
| for OLD_VER in "${MIGRATION_SOURCE_PHP_VERS[@]}"; do | ||
| sed -E -i "s|php${OLD_VER}(-fpm)?|php${NEW_PHP_VER}\1|g" "/var/www/admin/control-panel/api.php" | ||
| sed -E -i "/(php-fpm|fastcgi_pass|sock(et)?|service)/ s|php${OLD_VER}(-fpm)?|php${NEW_PHP_VER}\1|g" "/var/www/admin/control-panel/api.php" |
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.



Five overly-broad
sedsubstitutions inphp-update.shcould silently corrupt comments, string literals, and unrelated version references during PHP migration. TheSEEN_OLD_PHP_VERSdeduplication was also redundant againstSUPPORTED_PHP_VERSIONS.Software Version Updates
No version changes.
Changed Versions
N/A
Version Diff
Verification Checklist
Notes
Each replacement is now scoped to its relevant directive or value context, eliminating the risk of touching commented-out lines, documentation blocks, or unrelated PHP version references during migration.
Original prompt