aowow icon indicating copy to clipboard operation
aowow copied to clipboard

Exception - number_format(): Argument #1 ($num) must be of type float, string given

Open peycho opened this issue 10 months ago • 2 comments

I'm installing the whole setup in a fresh host.

When the installer reaches the SqlGen::generate() - filling aowow_item_stats with data - I've got the following error:

12:53:34          SqlGen::generate() - filling aowow_item_stats with data
12:53:34           - applying stats for enchantments
12:53:39             2656 enchantments parsed
12:53:39           - applying stats for items
12:53:52           * batch #5 (1000)Exception - number_format(): Argument #1 ($num) must be of type float, string given
   /web/setup/tools/sqlgen/item_stats.func.php(112)
#0 /web/setup/tools/sqlgen/item_stats.func.php(112): number_format()
#1 /web/setup/tools/sqlgen/item_stats.func.php(266): ItemStatSetup->writeStatsTable()
#2 /web/setup/tools/sqlGen.class.php(239): SetupScript@anonymous->generate()
#3 /web/setup/tools/clisetup/setup.func.php(294): SqlGen::generate()
#4 /web/setup/setup.php(40): setup()
#5 /web/aowow(10): require('...')
#6 {main}

System:

  • OS: Ubuntu 22.04
  • PHP version: PHP 8.1.2-1ubuntu2.15
  • revision used: ec1a2afc5f7aaa243de83e9552ce4fabc14ffcc5
  • Browser (in case of JavaScript / display errors): n/a
  • TrinityCore db TDB_full_world_335.21101_2021_10_15)

peycho avatar Apr 13 '24 13:04 peycho

Ok this works:

        // collect data and write to DB
        foreach ($this->iterate() as $__)
        {
            $updateFields = ['type' => Type::ITEM, 'typeId' => $this->id];

            foreach (@$this->json[$this->id] as $k => $v)
            {
                if (!in_array($k, $this->statCols) || !$v || $k == 'id')
                    continue;

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

            if (isset($this->itemMods[$this->id]))
            {
                foreach ($this->itemMods[$this->id] as $k => $v)
                {
                    if (!$v)
                        continue;
                    if ($str = Game::$itemMods[$k])
                        $updateFields[$str] = number_format((float)$v, 2, '.', '');
                }
            }

            DB::Aowow()->query('REPLACE INTO ?_item_stats (?#) VALUES (?a)', array_keys($updateFields), array_values($updateFields));
        }

peycho avatar Apr 13 '24 13:04 peycho

keep your workaround for now.

I'm currently rewriting how player stats are handled because of https://github.com/Sarjuuk/aowow/issues/389 and that will obvioulsy affect the item-stats setup step as a whole

Sarjuuk avatar Apr 17 '24 12:04 Sarjuuk

error source removed in https://github.com/Sarjuuk/aowow/commit/d16b08bb297dd1522040a01d1ba8958fba52d155

needs to be merged

Sarjuuk avatar Jun 16 '24 18:06 Sarjuuk

error source removed in Sarjuuk@d16b08b

needs to be merged

you know, you have push (and sync) permisions here xd

Aokromes avatar Jun 16 '24 19:06 Aokromes