]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17868 detection of incorrect hadnling of floats in version numbers - this should...
authorskodak <skodak>
Tue, 13 Jan 2009 09:04:09 +0000 (09:04 +0000)
committerskodak <skodak>
Tue, 13 Jan 2009 09:04:09 +0000 (09:04 +0000)
admin/index.php
lang/en_utf8/admin.php
lib/adminlib.php

index 8ea7f8cfa33104fad1bcf5fe56ae66d512414854..8c02f468f43a6d04385701f9d0ce97e39859ad66 100644 (file)
         print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
     }
 
+    if (is_float_problem()) {
+        print_error('phpfloatproblem', 'admin', '', $documentationlink);
+    }
+
 /// Check that config.php has been edited
 
     if ($CFG->wwwroot == "http://example.com/moodle") {
index 1f6d2f482ac9c5aa7bf1b47fd2f1ed18c72c9011..38087191a15f7e181f8124db137d2f592c8d9c42 100644 (file)
@@ -600,6 +600,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'] = 'Plugins';
index d913944a03169d7b221fef4616e524b2269c9d33..753d2ae733b895ce2cc5dc5ea57ea818be94e780 100644 (file)
@@ -954,6 +954,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.