Permalink
Browse files

MDL-28381 always verify PHP version in CLI scripts

The problem is that people may use different php binary for web and CLI.
  • Loading branch information...
1 parent 24654d9 commit 6b3d645e9bb495494f7da5271b09b16e2d0bdd0c @skodak skodak committed Aug 21, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/setup.php
View
@@ -183,6 +183,17 @@
}
}
+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);

0 comments on commit 6b3d645

Please sign in to comment.