Sarjuuk / aowow

Database viewer for TrinityCore based on aowow by @LordJZ, based on the JS-Engine of Wowhead
204 stars 217 forks source link

Error Solution: vsprintf(): Too few arguments #344

Closed opiums9 closed 6 months ago

opiums9 commented 2 years ago

If in the table "smart_scripts" action_type = 29 and action_param4 = 1 or action_type = 29 and action_param5 = 1, this will cause an error - vsprintf(): Too few arguments. You need to replace 1 with 0 in action_param4 and / or action_param5 then there will be no mistake.

During the debag, I found the following:

array(2) {
  [0]=>
  string(68) "(%7$d)?Angle: %7$.2f°:;(%8$d)? Some form of Quest Credit is given:;"
  [1]=>
  array(1) {
    [0]=>
    bool(true)
  }
}

Accordingly, the error has been confirmed. Is it possible to exclude this error without correcting the values in the database, or still leave it as it is?

Sarjuuk commented 2 years ago

https://github.com/Sarjuuk/aowow/blob/1bd752a60f0ca1892de4ffa1015df1297c8829ca/includes/smartAI.class.php#L984

Action params are already padded to 15 items, so this doesn't happen.

It happened regardless. >.>

opiums9 commented 2 years ago

Is it possible to use this function to check values?

function format($format, array $args)
{
    $pattern = "~%(?:(\d+)[$])?[-+]?(?:[ 0]|['].)?(?:[-]?\d+)?(?:[.]\d+)?[%bcdeEufFgGosxX]~";

    $countArgs = count($args);
    preg_match_all($pattern, $format, $expected);
    $countVariables = isset($expected[0]) ? count($expected[0]) : 0;

    return $countArgs !== $countVariables;
}

Source

Sarjuuk commented 2 years ago

Thats the most overkill thing i've seen .. ever.

I'll probably get around to it mid July.

Sarjuuk commented 6 months ago

fixed in 88b62730e18d522f002e9202b7e16cf8419bfef0

in corona time