diff --git a/src/scripts/common.sh b/src/scripts/common.sh index e7c06ec9..57792652 100644 --- a/src/scripts/common.sh +++ b/src/scripts/common.sh @@ -102,6 +102,11 @@ check_extension() { fi } +# Function to check if extension is shared +shared_extension() { + [ -e "${ext_dir:?}/$1.so" ] +} + # Function to enable cached extensions. enable_cache_extension() { deps=() @@ -129,7 +134,7 @@ enable_extension() { enable_extension_dependencies "$1" "$2" if [ -d /tmp/extcache/"$1" ]; then enable_cache_extension "$1" "$2" - elif ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then + elif ! check_extension "$1" && shared_extension "$1"; then echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null fi } @@ -164,13 +169,15 @@ disable_extension_dependents() { disable_extension() { extension=$1 if check_extension "$extension"; then - if [ -e "${ext_dir:?}"/"$extension".so ]; then + if shared_extension "$extension"; then disable_extension_helper "$extension" true (! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") || add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}" else add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP $semver as it not a shared extension" fi + elif shared_extension "$extension"; then + add_log "${tick:?}" ":$extension" "Disabled" else add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver" fi diff --git a/src/scripts/ext/blackfire.sh b/src/scripts/ext/blackfire.sh index 5eb28678..f9d3e3d1 100644 --- a/src/scripts/ext/blackfire.sh +++ b/src/scripts/ext/blackfire.sh @@ -6,7 +6,7 @@ add_blackfire() { platform=$(uname -s | tr '[:upper:]' '[:lower:]') extension_version=$(echo "$extension" | cut -d '-' -f 2) blackfire_ini_file="${pecl_file:-${ini_file[@]}}" - if [ ! -e "${ext_dir:?}/blackfire.so" ]; then + if ! shared_extension blackfire; then if [ "$extension_version" = "blackfire" ]; then if [[ ${version:?} =~ 5.[3-6] ]]; then extension_version='1.50.0' diff --git a/src/scripts/ext/ioncube.sh b/src/scripts/ext/ioncube.sh index 07bbdf0b..0f258009 100644 --- a/src/scripts/ext/ioncube.sh +++ b/src/scripts/ext/ioncube.sh @@ -7,11 +7,11 @@ add_license_log() { # Function to install ioncube. add_ioncube() { - if [ ! -e "${ext_dir:?}/ioncube.so" ]; then + if ! shared_extension ioncube; then status='Installed and enabled' os_name='lin' && [ "$(uname -s)" = "Darwin" ] && os_name='mac' get -s -n "" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp - sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "$ext_dir/ioncube.so" + sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "${ext_dir:?}/ioncube.so" fi echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1 add_extension_log "ioncube" "$status" diff --git a/src/scripts/ext/oci.sh b/src/scripts/ext/oci.sh index f5b53bc4..f0ddcb61 100644 --- a/src/scripts/ext/oci.sh +++ b/src/scripts/ext/oci.sh @@ -35,7 +35,7 @@ add_client() { # Function to install oci8 and pdo_oci. add_oci_helper() { - if ! [ -e "${ext_dir:?}/$ext.so" ]; then + if ! shared_extension "$ext"; then status='Installed and enabled' read -r "${ext}_LINUX_LIBS" <<< "libaio-dev" read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) --with-${ext/_/-}=instantclient,$oracle_client" diff --git a/src/scripts/ext/phalcon.sh b/src/scripts/ext/phalcon.sh index 72dfc9be..981294a7 100644 --- a/src/scripts/ext/phalcon.sh +++ b/src/scripts/ext/phalcon.sh @@ -10,7 +10,7 @@ add_phalcon_helper() { # Function to add phalcon3. add_phalcon3() { - if [ -e "${ext_dir:?}/phalcon.so" ]; then + if shared_extension phalcon; then phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) if [ "$phalcon_version" != "$extension_major_version" ]; then add_phalcon_helper @@ -24,10 +24,10 @@ add_phalcon3() { # Function to add phalcon4. add_phalcon4() { - if [ -e "${ext_dir:?}/psr.so" ] && ! php -m | grep -i -q -w psr; then + if shared_extension phalcon && ! php -m | grep -i -q -w psr; then echo "extension=psr.so" | sudo tee -a "${ini_file:?}" fi - if [ -e "$ext_dir/phalcon.so" ]; then + if shared_extension phalcon; then if php -m | grep -i -q -w psr; then phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) if [ "$phalcon_version" != "$extension_major_version" ]; then diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 335b0fe5..99f8f5e9 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -37,7 +37,7 @@ add_pdo_extension() { else ext=$1 ext_name=$1 - if [ -e "$ext_dir"/pdo.so ]; then + if shared_extension pdo; then disable_extension_helper pdo echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" >/dev/null 2>&1 fi diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 975fcceb..ae22670c 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -300,6 +300,8 @@ Function Disable-Extension() { } else { Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension" } + } elseif(Test-Path $ext_dir\php_$extension.dll) { + Add-Log $tick ":$extension" "Disabled" } else { Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)" }