What
The per-site DB upgrade block in docker/openemr/7.0.4/upgrade/fsupgrade-1.sh (and its byte-identical copy at docker/openemr/8.0.0/upgrade/fsupgrade-1.sh) writes a TEMPsql_upgrade.php, runs sed -i against it three times with heavy shell-escaped $/bracket noise, runs it with php -f, then deletes it. The whole shuffle can be a single pipeline:
{
printf '<?php $_GET["site"] = "%s"; ?>' "${sitename}"
cat /var/www/localhost/htdocs/openemr/sql_upgrade.php
} | sed -e "/input type='submit'/d" \
-e "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" \
-e "s/^[ \t]*\$form_old_version[ \t=].*\$/\$form_old_version = \"${priorOpenemrVersion}\";/" \
| php
Why
- Eliminates a temp file on the image's writable layer.
- Collapses three
sed -i calls into one sed -e … -e … -e ….
- Removes the
-i dependency (GNU-specific flag) and trims shell escaping.
Considerations
- Verify whether
sql_upgrade.php references __FILE__ or __DIR__ — piping to php from stdin changes those values vs php -f <path>. If it does, the pipeline needs a small shim or this change isn't safe.
- Test the 5.0.1 → 5.0.2 upgrade path against a real fixture before landing.
- Apply to both 7.0.4 and 8.0.0 copies in lockstep.
Originally suggested by @kojiromike in review of #652.
What
The per-site DB upgrade block in
docker/openemr/7.0.4/upgrade/fsupgrade-1.sh(and its byte-identical copy atdocker/openemr/8.0.0/upgrade/fsupgrade-1.sh) writes aTEMPsql_upgrade.php, runssed -iagainst it three times with heavy shell-escaped$/bracket noise, runs it withphp -f, then deletes it. The whole shuffle can be a single pipeline:{ printf '<?php $_GET["site"] = "%s"; ?>' "${sitename}" cat /var/www/localhost/htdocs/openemr/sql_upgrade.php } | sed -e "/input type='submit'/d" \ -e "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" \ -e "s/^[ \t]*\$form_old_version[ \t=].*\$/\$form_old_version = \"${priorOpenemrVersion}\";/" \ | phpWhy
sed -icalls into onesed -e … -e … -e ….-idependency (GNU-specific flag) and trims shell escaping.Considerations
sql_upgrade.phpreferences__FILE__or__DIR__— piping tophpfrom stdin changes those values vsphp -f <path>. If it does, the pipeline needs a small shim or this change isn't safe.Originally suggested by @kojiromike in review of #652.