From ac8b7d54f81f7b3879a7e21c96b0d182a00618d2 Mon Sep 17 00:00:00 2001 From: Platonides Date: Fri, 27 Jul 2012 19:00:40 +0200 Subject: [PATCH] Improve detection of php binary. - Add php binary and a program which might be set as $PHP. - Check for the correct php version. The break shell builtin is not too commonly used, but should beperfectly safe to use, since it's specified by POSIX http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#break Change-Id: Iefbe991426f0e9a7178363a30b613f57110e1953 --- maintenance/dev/includes/php.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/maintenance/dev/includes/php.sh b/maintenance/dev/includes/php.sh index 3021b93b17..f5b712ac6a 100644 --- a/maintenance/dev/includes/php.sh +++ b/maintenance/dev/includes/php.sh @@ -1,12 +1,14 @@ # Include-able script to determine the location of our php if any +# We search for a environment var called PHP, native php, +# a local copy, home directory location used by installphp.sh +# and previous home directory location +# The binary path is returned in $PHP if any -if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ]; then - # Quick local copy - PHP="$DEV/php/bin/php" -elif [ -d "$HOME/.mediawiki/php" -a -x "$HOME/.mediawiki/php/bin/php" ]; then - # Previous home directory location to install php in - PHP="$HOME/.mediawiki/php/bin/php" -elif [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then - # Previous home directory location to install php in - PHP="$HOME/.mwphp/bin/php" -fi +for binary in $PHP `which php || true` "$DEV/php/bin/php" "$HOME/.mediawiki/php/bin/php" "$HOME/.mwphp/bin/php" ]; do + if [ -x "$binary" ]; then + if "$binary" -r 'die(!version_compare(PHP_VERSION, "5.4", ">="));'; then + PHP="$binary" + break + fi + fi +done -- 2.20.1