From 8de5d7b987fcbf5bf850eba40b5794216ccc1298 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 21 Aug 2011 12:19:59 +0200 Subject: [PATCH] MDL-28381 always verify PHP version in CLI scripts The problem is that people may use different php binary for web and CLI. --- lib/setup.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/setup.php b/lib/setup.php index ba2d627fb33..f8990b089d7 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -183,6 +183,17 @@ if (file_exists("$CFG->dataroot/climaintenance.html")) { } } +if (CLI_SCRIPT) { + // sometimes people use different PHP binary for web and CLI, make 100% sure they have the supported PHP version + if (version_compare(phpversion(), '5.3.2') < 0) { + $phpversion = phpversion(); + // do NOT localise - lang strings would not work here and we CAN NOT move it to later place + echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n"; + echo "Some servers may have multiple PHP versions installed, are you using the correct executable?\n"; + exit(1); + } +} + // Detect ajax scripts - they are similar to CLI because we can not redirect, output html, etc. if (!defined('AJAX_SCRIPT')) { define('AJAX_SCRIPT', false);