EasyStore Ratings.php Fatal On Product Page - Question | JoomShaper

EasyStore Ratings.php Fatal On Product Page

Matt

Matt

EasyStore 1 week ago

I ran into what looks like a bug in EasyStore on a product page.

The page was intermittently failing to load. At first it looked like a mixed content issue, but after testing with curl it turned out the page was returning a 500 over HTTP/1.1, and HTTP/2 was failing with:

curl: (92) HTTP/2 stream 0 was closed cleanly, but before getting all response header fields, treated as error

The Joomla log pointed to this error:

Uncaught Throwable of type ValueError thrown with message "str_repeat(): Argument #2 ($times) must be greater than or equal to 0"
[ROOT]/components/com_easystore/layouts/ratings.php(41)

The relevant part of ratings.php is:

$fullStars = floor($count);

echo str_repeat($star, $fullStars);

if ($count - $fullStars >= 0.5) {
    echo $halfStar;
    $fullStars++;
}

echo str_repeat($emptyStar, 5 - $fullStars);

I patched the file locally by clamping the rating value before rendering, and that immediately fixed the product page.

What is confusing is that the review form only allows selecting up to 5 stars, so this does not appear to be caused by manually entering an invalid rating through the UI.

It looks like there may be a case where the value reaching ratings.php can still end up outside the expected 0 to 5 range, and because of that line, PHP 8 throws a fatal instead of failing safely.

Might be worth reviewing how the rating value is calculated or passed into ratings.php, and possibly adding a defensive clamp there so the page cannot fatal if the value is ever out of range.

0
1 Answers
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 5 days ago #221109

Hi,

Apologies for the inconvenience and for the delayed response over the weekend.

Thank you for the detailed report and for identifying the root cause. I have forwarded this issue to our development team for further investigation. They will review the rating value handling and the scenario you described.

I will keep you updated as soon as I receive any feedback or progress from them.

We appreciate your patience and understanding.

Best regards

0