azerothcore / aowow

Database viewer AoWoW adapted for AzerothCore
https://wowgaming.altervista.org/aowow/
33 stars 33 forks source link

Argument #1 ($num) must be of type float, string given #40

Open helldragonpz opened 10 months ago

helldragonpz commented 10 months ago

Describe the bug and how to reproduce it During installation, i received an error and I'm not quite sure how to proceed.

Exception - number_format(): Argument #1 ($num) must be of type float, string given
   /var/www/html/database/setup/tools/sqlgen/item_stats.func.php(112)
#0 /var/www/html/database/setup/tools/sqlgen/item_stats.func.php(112): number_format()
#1 /var/www/html/database/setup/tools/sqlgen/item_stats.func.php(268): ItemStatSetup->writeStatsTable()
#2 /var/www/html/database/setup/tools/sqlGen.class.php(239): SetupScript@anonymous->generate()
#3 /var/www/html/database/setup/tools/clisetup/setup.func.php(292): SqlGen::generate()
#4 /var/www/html/database/setup/setup.php(40): setup()
#5 /var/www/html/database/aowow(10): require('...')
#6 {main}

System:

helldragonpz commented 10 months ago

Change this line in the file /tools/clisetup/setup.func.php

$updateFields[$k] = number_format($v, 2, '.', '');

To this

$updateFields[$k] = number_format((float)$v, 2, '.', '');
pangolp commented 9 months ago

We would have to see if this change does not affect other versions of PHP and if not, check the version and based on that, tell it to use one method or another. Anyway, thanks for the suggestion.

Helias commented 3 months ago

I've recently reinstalled AoWoW locally without using the client-data and I did not encounter this issue, I used PHP 8.x. If you encounter the issue again let me know and re-open this issue

Helias commented 3 months ago

Another user solved using a different PHP version 7.x I think we should fix any compatibility with any PHP version as much as we can, but for now I can recommend only this

pangolp commented 3 months ago

Or we could, check for now, in that line where you want to make the change, the php version, and if it is 8, use this code, and if it is 7, use the current code. Although I personally have never used this code, so I would have to do some research on it first.

if (version_compare(PHP_VERSION, '8.0.0', '<'))
{
    $updateFields[$k] = number_format($v, 2, '.', '');
}
else
{
    $updateFields[$k] = number_format((float)$v, 2, '.', '');
}

If you want, I can make a pull request, but I can't test it. If anyone wants to test it, no problem.