Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
helldragonpz opened this issue Jan 7, 2024 · 5 comments
Open

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

helldragonpz opened this issue Jan 7, 2024 · 5 comments

Comments

@helldragonpz
Copy link

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
Copy link
Author

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
Copy link

pangolp commented Feb 12, 2024

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
Copy link
Member

Helias commented Aug 23, 2024

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 Helias closed this as completed Aug 23, 2024
@Helias Helias reopened this Aug 30, 2024
@Helias
Copy link
Member

Helias commented Aug 30, 2024

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
Copy link

pangolp commented Aug 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants