Bug: Star Rating element throws PHP Deprecated errors on PHP 8.1 and PHP 8.2
-
The Star Rating element is throwing PHP deprecation errors when running PHP 8.1 or PHP 8.2. These errors are visible on the frontend when WP_DEBUG is enabled, breaking the page layout.
Environment:
- Bricks Builder (latest version)
- Bricksable (latest version)
- PHP 8.1 / PHP 8.2 (both affected)
- SiteGround hosting
Error message:
Deprecated: Implicit conversion from float-string "4.5" to int loses precision in .../bricksable/includes/elements/star-rating/element-star-rating.php on line 562 Deprecated: Implicit conversion from float 0.5 to int loses precision in .../bricksable/includes/elements/star-rating/element-star-rating.php on line 564Root cause:
As of PHP 8.1, implicit conversion from float to int is deprecated (per PHP RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate). The Star Rating element is passing float values (e.g. 4.5, 0.5) where integers are expected, which triggers the deprecation notice on PHP 8.1+ and will become a fatal TypeError in PHP 9.
Impact:
With WP_DEBUG enabled, the raw PHP error is printed directly into the page HTML, visible to all visitors and breaking the page output. Even with WP_DEBUG disabled, the error still occurs silently in the background.
I had to downgrade from PHP 8.2 all the way to PHP 8.0.30 to stop the errors, as PHP 8.1 also triggers them.
Suggested fix:
In
element-star-rating.phparound lines 562-564, the float values should be explicitly cast to int or handled withintval()/round()before being used in an integer context. For example:// Instead of: $value = "4.5"; // implicit float-to-int // Use: $value = (int) round(4.5); // or $value = intval("4.5");
You must be logged in to reply to this topic.