Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Check that data is countable before running count.
Browse files Browse the repository at this point in the history
Ensure the data is countable before running `count()` on it to avoid a
Fatal Error.
  • Loading branch information
danielwrobert committed Nov 8, 2023
1 parent 159322f commit 6428e31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Templates/SingleProductTemplateCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function( $carry, $block ) {
$carry[] = array( $block );
return $carry;
}
$last_element_index = count( $carry ) - 1;
$last_element_index = ( is_countable( $carry ) ? count( $carry ) : 0 ) - 1;
if ( isset( $carry[ $last_element_index ][0]['blockName'] ) && 'core/template-part' !== $carry[ $last_element_index ][0]['blockName'] ) {
$carry[ $last_element_index ][] = $block;
return $carry;
Expand Down

0 comments on commit 6428e31

Please sign in to comment.