Skip to content

Commit

Permalink
Merge pull request #253 from boesing/feature/pdo-extension-driver
Browse files Browse the repository at this point in the history
Handle PDO driver extensions
  • Loading branch information
Ocramius authored Feb 6, 2025
2 parents 9bd1c14 + 329c927 commit ff2b3dd
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions scripts/extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,22 @@ declare -a EXTENSIONS=(${@:2})
ENABLED_EXTENSIONS=$(php -m | tr '[:upper:]' '[:lower:]' | egrep -v '^[\[]' | grep -v 'zend opcache')
EXTENSIONS_TO_INSTALL=()

add_extension_to_install() {
local EXTENSION=$1

# Prevent duplicates
for TO_BE_INSTALLED in "${EXTENSIONS_TO_INSTALL[@]}"; do
if [[ "${TO_BE_INSTALLED}" == "${EXTENSION}" ]]; then
return
fi
done

EXTENSIONS_TO_INSTALL+=("${EXTENSION}")
}

# Loop through known statically compiled/installed extensions, and enable them.
# NOTE: when developing on MacOS, remove the quotes while implementing your changes and re-add the quotes afterwards.
for EXTENSION in "${EXTENSIONS[@]}"; do

# Check if extension is already enabled
REGULAR_EXPRESSION=\\b${EXTENSION}\\b
if [[ "${ENABLED_EXTENSIONS}" =~ $REGULAR_EXPRESSION ]]; then
Expand All @@ -112,7 +124,32 @@ for EXTENSION in "${EXTENSIONS[@]}"; do
continue;
fi

EXTENSIONS_TO_INSTALL+=("$EXTENSION")
if [[ "${EXTENSION}" =~ ^pdo_ ]]; then
case "${EXTENSION}" in
"pdo_mysql")
add_extension_to_install "mysql"
;;
"pdo_sqlite")
add_extension_to_install "sqlite3"
;;
"pdo_pgsql")
add_extension_to_install "pgsql"
;;
*)
echo "Unsupported PDO driver extension \"${EXTENSION}\" cannot is not (yet) supported."
echo -n "In case the extension is not available already, please consider using .pre-install.sh to install"
echo " the appropriate extension."
echo -n "If you think its worth to have the PDO driver extension installed automatically, please create"
echo " a feature request on github: https://github.com/laminas/laminas-continuous-integration-action/issues"
continue;
;;
esac

add_extension_to_install "pdo"
continue;
fi

add_extension_to_install "${EXTENSION}"
done

# If by now the extensions list is not empty, install missing extensions.
Expand Down

0 comments on commit ff2b3dd

Please sign in to comment.