diff --git a/admin/index.php b/admin/index.php index 2340eb39df9..5d7a9518d8b 100644 --- a/admin/index.php +++ b/admin/index.php @@ -61,6 +61,10 @@ error("The PHP server variable 'file_uploads' is not turned On - $documentationlink"); } + if (is_float_problem()) { + print_error('phpfloatproblem', 'admin', '', $documentationlink); + } + if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')'); } diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 5e81a75050a..800e791b6df 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -565,6 +565,7 @@ $string['performance'] = 'Performance'; $string['pgcluster'] = 'PostgreSQL Cluster'; $string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.'; $string['php50restricted'] = 'PHP 5.0.x has a number of known problems, please upgrade to 5.1.x or downgrade to 4.3.x or 4.4.x'; +$string['phpfloatproblem'] = 'Detected unexpected problem in handling of PHP float numbers - $a'; $string['pleaseregister'] = 'Please register your site to remove this button'; $string['pleaserefreshregistration'] = 'Your site has been registered with moodle.org, please consider updating the registration if significant changes happened since your last update, on $a'; $string['plugins'] = 'Modules'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 5744f5e574b..d27c2941472 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -749,6 +749,18 @@ function admin_critical_warnings_present() { return $SESSION->admin_critical_warning; } +/** + * Detects if float support at least 10 deciman digits + * and also if float-->string conversion works as expected. + * @return bool true if problem found + */ +function is_float_problem() { + $num1 = 2009010200.01; + $num2 = 2009010200.02; + + return ((string)$num1 === (string)$num2 or $num1 === $num2 or $num2 <= (string)$num1); +} + /** * Try to verify that dataroot is not accessible from web. * It is not 100% correct but might help to reduce number of vulnerable sites.