Abort if installing PHP extensions introduces new PHP startup errors (#541)

Test: bcmath+xdebug
pull/542/head 1.4.28
Michele Locati 2022-03-25 08:59:08 +01:00 committed by GitHub
parent fa7e016989
commit 7ba4e7a920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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