Blade Composer triggers a 500 error only for some posts


I have a composer with this code:

 $player_1 = get_field('player_1', get_the_ID());
        if ($player_1['percentage_points_won_opponent_first_serve'] == 'N/A') {
            $player_1['percentage_points_won_opponent_first_serve'] = round(($player_1['points_won_opponent_first_serve'] / $player_1['points_total_opponent_first_serve']) * 100);

On some posts, even if $player_1_stats[‘percentage_points_won_opponent_second_serve’] is not equal to ‘N/A’, the composer does the round operation, which triggers an error.

Where would you check to understand the issue, or what could I do to avoid an error, please?

I would step through it with xdebug, or var_dump && die to find out more about the point that it is erroring.

I can’t help but notice you only check for 0 on the later totals, I suspect a divide by zero would be probable. But looking at the error logs for what error message is thrown from the 500 is a good idea too.

1 Like

In fact, it shouldn’t even trigger the conditional because the value is like 29.97 and not N/A.

I don’t get why it goes into the conditional.

And found it, it was in another Composer. The post id retrieved was not the good one. Thank you, var dump helped me a lot!

1 Like