Description:
Bug Description
Fatal PHP error occurs when render_tag() receives an array instead of a string, specifically when processing featured images in Bricks query loops.
Error Message
Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in
/wp-content/plugins/bricks-api-bridge/includes/class-dynamic-tags.php:79
Steps to Reproduce
- Create a Bricks query loop that displays posts
- Add an image element using
{featured_image} dynamic data
- View the page on the frontend
Root Cause
In class-dynamic-tags.php line 79, the render_tag() method calls strpos($tag, '{bab_var:') without checking if $tag is a string. When Bricks passes image
metadata (an array) through the bricks/dynamic_data/render_tag filter, this causes a type error.
Proposed Fix
Add a type check at the beginning of the render_tag() method:
public function render_tag( $tag, $post, $context ) {
// If $tag is not a string (e.g., array from image metadata), return it unchanged
if ( ! is_string( $tag ) ) {
return $tag;
}
if ( strpos( $tag, '{bab_var:' ) !== 0 ) {
return $tag;
}
// ... rest of method
}
Environment
- Plugin Version: 1.0.0
- PHP Version: 7.4+
- Bricks Builder: Latest
- WordPress: 5.6+
Impact
This is a fatal error that crashes pages using query loops with featured images.
Description:
Bug Description
Fatal PHP error occurs when
render_tag()receives an array instead of a string, specifically when processing featured images in Bricks query loops.Error Message
Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in
/wp-content/plugins/bricks-api-bridge/includes/class-dynamic-tags.php:79
Steps to Reproduce
{featured_image}dynamic dataRoot Cause
In
class-dynamic-tags.phpline 79, therender_tag()method callsstrpos($tag, '{bab_var:')without checking if$tagis a string. When Bricks passes imagemetadata (an array) through the
bricks/dynamic_data/render_tagfilter, this causes a type error.Proposed Fix
Add a type check at the beginning of the
render_tag()method: