Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions docker/openemr/flex/utilities/devtoolsLibrary.source
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,14 @@ demoData() {
# ============================================================================

# Upgrades OpenEMR database from a specified version to the current version.
# This function runs OpenEMR's sql_upgrade.php script programmatically
# by modifying it to run non-interactively.
# Invokes sql_upgrade.php in CLI mode (added in openemr/openemr#11906).
#
# Parameters:
# $1: Original OpenEMR version (e.g., "5.0.0", "6.0.0")
#
# Process:
# 1. Creates a temporary version of sql_upgrade.php
# 2. Modifies it to run non-interactively (auto-submit form)
# 3. Sets the source version
# 4. Executes the upgrade script
# 5. Cleans up temporary file
#
# Must call prepareVariables() before calling this function.
upgradeOpenEMR() {
sed -e "s@!empty(\$_POST\['form_submit'\])@true@" < /var/www/localhost/htdocs/openemr/sql_upgrade.php > /var/www/localhost/htdocs/openemr/sql_upgrade_temp.php
sed -i "s@\$form_old_version = \$_POST\['form_old_version'\];@\$form_old_version = '${1}';@" /var/www/localhost/htdocs/openemr/sql_upgrade_temp.php
sed -i "1s@^@<?php \$_GET['site'] = 'default'; ?>@" /var/www/localhost/htdocs/openemr/sql_upgrade_temp.php
php -f /var/www/localhost/htdocs/openemr/sql_upgrade_temp.php
rm -f /var/www/localhost/htdocs/openemr/sql_upgrade_temp.php
php -f /var/www/localhost/htdocs/openemr/sql_upgrade.php -- --from="${1}"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implementation always forced the upgrade to run against the default site by injecting $_GET['site'] = 'default';. This new CLI invocation no longer sets the site context at all, which can change behavior (or fail) in multisite-enabled containers. Consider passing the site explicitly in CLI mode (or otherwise setting the site to preserve the prior default-site behavior).

Copilot uses AI. Check for mistakes.
}

# ============================================================================
Expand Down
Loading