Implicit conversion from float 7.25
-
Hello,
When running IP2Location Redirection plugin (latest version) on PHP 8.3, the following deprecation warning is logged:
PHP Deprecated: Implicit conversion from float 7.25 to int loses precision in ip2location-redirection.php on line 3005
Issue:
In the cidr_match() function, line 3005:
$binMask = str_repeat(‘f’, $mask / 4);
When $mask is a value like 29, dividing by 4 produces a float (7.25). The str_repeat() function expects an integer for the second parameter. PHP 8.x now raises a deprecation warning for this implicit conversion.Suggested Fix:
Cast the division result to int explicitly:
$binMask = str_repeat(‘f’, (int)($mask / 4));
Environment:
PHP 8.3
WordPress 6.9
Thank you for your work on this plugin.Didier.
You must be logged in to reply to this topic.