Error Installing Moodle "handling of PHP float numbers"

Error Installing Moodle "handling of PHP float numbers"

by Paul Martin -
Number of replies: 16
I am trying to do a fresh install of Moodle for a my senior design thesis. I got all the way up thru where the Moodle install creates the config.php file. On the next screen I get the following error.


"Detected unexpected problem in handling of PHP float numbers"

Screenshot: http://www.pauljmartin.net/aiw/imd460/error.png


What is wrong and more important, how do I correct it?
Average of ratings: -
In reply to Paul Martin

Re: Error Installing Moodle "handling of PHP float numbers"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is related to MDL-17868.

Moodle internal version numbers look like 2007101533.03. The PHP documentation promises that PHP stores floating point numbers using 64 bit precision, which gives at least 15 significant figures in decimal, so there should be not problem accurately storing and comparing these numbers during the upgrade.

However, we had some reports of problems that seemed to be due to PHP failing to compare numbers like 2007101533.01 and 2007101533.02. (It would compare 2007101533.02 <= 2007101533.01 as true! which breaks the upgrade, which is really bad!) So we (well Petr) added some checks before it starts the upgrade, to try to ensure that PHP was not screwing up floating comparisons. So at least now, if your PHP is broken, it will not mess up your database by starting an install/upgrade that will probably fail.

That was all done quite recently, The test is in adminlib.php:
/**
 * 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);
}

I don't suppose you could pick that apart, and try to work out which bit of that is failing on your version of PHP, and tell us exactly which version of PHP that is. That would really help us get to the bottom of this problem. Thanks.

In reply to Tim Hunt

Re: Error Installing Moodle "handling of PHP float numbers"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I've just been doing some searching in the PHP bug database, but there is not much there that looks suspicious.

The closest thing I can find is http://bugs.php.net/bug.php?id=43487 (hey! I remember that bug, it caused problems for someone using numerical questions in the quiz once before).


In reply to Tim Hunt

Re: Error Installing Moodle "handling of PHP float numbers"

by Richard Enison -
TH,

The solution to this problem is ridiculously simple. Treat the internal version numbers as text fields of 13 characters and compare them as such.

RLE
In reply to Richard Enison

Re: Error Installing Moodle "handling of PHP float numbers"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think there was a good reason why that does not work, but I can't remember what it was.
In reply to Paul Martin

Re: Error Installing Moodle "handling of PHP float numbers"

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Could you please tell us what exact version of PHP and OS are you using on the server?
In reply to Petr Skoda

Re: Error Installing Moodle "handling of PHP float numbers"

by Paul Martin -
Operating system Linux

Apache version
1.3.37 (Unix)

PHP version5.2.5
In reply to Paul Martin

Re: Error Installing Moodle "handling of PHP float numbers"

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
We would need much more information, like the name of linux distrubtion and exact version including update repositories used, method of installation of PHP (package name, package repository) or compilation flags if compiled manually. Anything that could help us reproduce this problem.
In reply to Petr Skoda

Re: Error Installing Moodle "handling of PHP float numbers"

by Bill Thompson -
I am having the same issue.

Hosting package siteground
Server Name serv01
cPanel Version 11.24.4-RELEASE
cPanel Build 33472
Theme sg
Apache version 1.3.37 (Unix)
PHP version 5.2.5
MySQL version 5.0.67-community-log
Architecture i686
Operating system Linux
Shared Ip Address xxx.xxx.xxx.xxx
Path to sendmail /usr/sbin/sendmail
Path to PERL /usr/bin/perl
Kernel version 2.6.24.3-grsec-sg1

I had an 1.8.4 installation that was working correctly. I unzipped the files of the lastest 1.9.4 last night into the correct directory. I then began to receive the same error the previous gentleman did.
In reply to Paul Martin

Re: Error Installing Moodle "handling of PHP float numbers"

by Richard Enison -
PM,

If you could run phpinfo and attach a copy of the resulting page to a post here, that would probably answer most of PS's questions. Just don't paste it into the post itself; it's way too long.

RLE
In reply to Richard Enison

Re: Error Installing Moodle "handling of PHP float numbers"

by Gautam Saha -
Hi,
I am having the same problem.
Attached is the phpinfo in my siteground server.
In reply to Gautam Saha

Re: Error Installing Moodle "handling of PHP float numbers"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thank you very much for posting that.

The setting that leaps out at me from there is the one called precision. That controls how floating point numbers are converted to strings, and is normally 14. On your server it is set to 6.

Please can you try setting it back to 14 again. There are several ways to do that. You can control PHP configuration settings from either a php.ini file, a .htaccess file, or by calling a function.

For example, you could add
ini_set('precision', 14);
to your config.php file.

After doing that, check that the phpinfo shows the new setting, then try the moodle upgrade/install again. Thanks.

MDL-18253 is the bug to follow this.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Error Installing Moodle "handling of PHP float numbers"

by Gautam Saha -
Thanks so much Tim.
I will try that today.
I wonder if this precision setting is also affecting the other problem I am having with "online user" block.
On version 1.93 installed with fantastico, this block is very very erratic. Sometimes online users will show up in this log immediately as it should and sometimes it wont show up. Also the status of the users when it shows up gets stuck. It is like it is not comunicating with the block_online_user.php
very frustrating since I cant track if this is a sql error or cron error or simply high lag on siteground server.
Meanwhile here is the response from Siteground tech support:

Hello,

Thank you for your patience.

After further investigation on the issue, and further consultation with our Senior Support department, I am afraid that we don't have any resolution on the issue yet.

Our suggestion is that this is due to an application incompatibility or "bug", which should be fixed by the developers soon.

I am afraid I can only advise you to install to an earlier version of Moodle, which should cause no problems, or simply use Fantastico to install Moodle.

I am really sorry for any inconvenience.

Should you have any further questions or comments, please do not hesitate to contact us and we will be happy to assist you!

Best Regards,

Evgeniy
Support Team
In reply to Gautam Saha

Re: Error Installing Moodle "handling of PHP float numbers"

by Richard Enison -
GS,

Amazing. A post showing violations of both of my "rules". I have been proclaiming these rules in this forum for months now, especially the first one, until my fingertips are sore. Here they are:
  1. Don't use Fantastico to install Moodle.
  2. Don't ask your web host's tech. support for help with a Moodle problem. They will most likely end up blaming their own shortcomings on a non-existent Moodle bug. [EDIT: it would be better to phrase your question in terms of PHP, MySQL, Apache, IIS, Linux, Windows, etc. Just don't mention Moodle.]
Just do a search of this forum for the word Fantastico. You'll see. To cut down on the size of the list of search results, you can do an advanced search for that word in posts from me. To cut it down further, search for posts also containing the word rules.

RLE
In reply to Richard Enison

Re: Error Installing Moodle "handling of PHP float numbers"

by Colin Matheson -
Thank you for your help. I use fantastico to easily set up test/pilot moodles. The php precision error is the first problem I have encountered with it. I agree it would be bad to run a production server on a fantastico install, however it does have its uses. I can get a pilot Moodle running (and customized) for a few hundred students for less than $100/year. If they like it, then I suggest they talk to a Moodle Partner.

In reply to Tim Hunt

Re: Error Installing Moodle "handling of PHP float numbers"

by Monico Briseño -
Picture of Testers
Hi, Tim. As Gautaam saha, I had problem with moodle upgrade procedure on Siteground site. After, I included the line 'ini_set..' in config.php file, the upgrade procedure works fine. Thanks.

Cheers

Monico