aowow icon indicating copy to clipboard operation
aowow copied to clipboard

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

Open helldragonpz opened this issue 1 year ago • 5 comments

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:

  • OS: Ubuntu LTS 20.04
  • PHP version: 8.2
  • revision used: d67cf7f
  • Browser (in case of JavaScript / display errors):
  • AzerothCore: yes

helldragonpz avatar Jan 07 '24 07:01 helldragonpz

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, '.', '');

helldragonpz avatar Jan 07 '24 07:01 helldragonpz

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.

pangolp avatar Feb 12 '24 21:02 pangolp

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 avatar Aug 23 '24 15:08 Helias

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

Helias avatar Aug 30 '24 20:08 Helias

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.

pangolp avatar Aug 30 '24 22:08 pangolp