From 7ba4e7a920ff1b04c110972f3883bc02853e06c7 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Fri, 25 Mar 2022 08:59:08 +0100 Subject: [PATCH] Abort if installing PHP extensions introduces new PHP startup errors (#541) Test: bcmath+xdebug --- install-php-extensions | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index cec8c8b..e734c7c 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -1435,9 +1435,10 @@ checkModuleWorking() { checkModuleWorking_inientry=extension fi printf 'Check if the %s %s can be loaded... ' "$checkModuleWorking_inientry" "$1" - checkModuleWorking_err="$(php -d "$checkModuleWorking_inientry=$checkModuleWorking_file" -r 'return;' 2>&1 || true)" - if test -n "$checkModuleWorking_err"; then - printf 'Error loading the "%s" extension from "%s":\n%s\n' "$1" "$checkModuleWorking_file" "$checkModuleWorking_err" >&2 + checkModuleWorking_errBefore="$(php -r 'return;' 2>&1 || true)" + checkModuleWorking_errAfter="$(php -d "$checkModuleWorking_inientry=$checkModuleWorking_file" -r 'return;' 2>&1 || true)" + if test "$checkModuleWorking_errAfter" != "$checkModuleWorking_errBefore"; then + printf 'Error loading the "%s" extension from "%s":\n%s\n' "$1" "$checkModuleWorking_file" "$checkModuleWorking_errAfter" >&2 return 1 fi printf 'ok.\n' @@ -2127,6 +2128,7 @@ EOF fi ;; esac + installBundledModule_errBefore="$(php -r 'return;' 2>&1 || true)" docker-php-ext-install -j$(getProcessorCount) "$1" case "$1" in imap) @@ -2137,9 +2139,9 @@ EOF esac ;; esac - installBundledModule_err="$(php -r 'return;' 2>&1 || true)" - if test -n "$installBundledModule_err"; then - printf 'PHP has problems after installing the "%s" extension:\n%s\n' "$1" "$installBundledModule_err" >&2 + installBundledModule_errAfter="$(php -r 'return;' 2>&1 || true)" + if test "$installBundledModule_errAfter" != "$installBundledModule_errBefore"; then + printf 'PHP has problems after installing the "%s" extension:\n%s\n' "$1" "$installBundledModule_errAfter" >&2 rm "$PHP_INI_DIR/conf.d/docker-php-ext-$1.ini" || true return 1 fi