WAIT:: (Image-) Element disappears after dragging into Block -> Column and causes php error

Browser: Firefox 141
OS: macOS 12.7.6
PHP: 8.2.29
WP: 6.8.2

Hi there,
i’ve currently ran into a bug whick looks like already mentioned here:
https://forum.bricksbuilder.io/t/solved-when-we-drag-elements-inside-block-they-disappeared-from-structure-and-canvas/25160

Issue:
After dragging an image element into a block > column > {image here} structure, the error appeared and throw a php error.
Error is pasted below and comes from an array entry where the item is “div” but should be “image”.
The bad thing on that was, that only a direct database change have helped me to get the whole page back working.

DB Data:
The meta_value contained the following data (pretty-printed for better readability):

{
  "id": "xuszci",
  "name": "div",  //  <- should be "image"
  "parent": 0,    //  <- no parent = floating element
  "children": [],
  "settings": {},
  "cid": "awkrnr",
  "properties": {
    "mgjbqj": {
      "id": 70,
      "filename": "my-logo.png",
    }
  }
} 

… which causes to to interrupt page rendering because it throws a php error:

Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /html/wordpress/wp-content/themes/bricks/includes/elements/base.php:1843 Stack trace: #0 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(1843): strpos(Array, '...') #1 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2586): Bricks\Element->set_root_attributes() #2 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #3 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #4 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #5 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #6 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #7 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #8 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #9 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #10 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #11 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #12 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #13 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #14 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #15 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #16 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #17 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #18 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #19 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #20 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #21 /html/wordpress/wp-content/themes/bricks/includes/elements/container.php(934): Bricks\Frontend::render_element(Array) #22 /html/wordpress/wp-content/themes/bricks/includes/elements/base.php(2625): Bricks\Element_Container->render() #23 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(639): Bricks\Element->init() #24 /html/wordpress/wp-content/themes/bricks/includes/frontend.php(784): Bricks\Frontend::render_element(Array) #25 /html/wordpress/wp-content/themes/bricks/includes/builder.php(1454): Bricks\Frontend::render_data(Array, '...') #26 /html/wordpress/wp-content/themes/bricks/includes/builder.php(313): Bricks\Builder::builder_data(17) #27 /html/wordpress/wp-includes/class-wp-hook.php(324): Bricks\Builder->enqueue_scripts('') #28 /html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #29 /html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #30 /html/wordpress/wp-includes/script-loader.php(2299): do_action('...') #31 /html/wordpress/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts('') #32 /html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #33 /html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #34 /html/wordpress/wp-includes/general-template.php(3192): do_action('...') #35 /html/wordpress/wp-content/themes/bricks/header.php(7): wp_head() #36 /html/wordpress/wp-includes/template.php(810): require_once('...') #37 /html/wordpress/wp-includes/template.php(745): load_template('...', true, Array) #38 /html/wordpress/wp-includes/general-template.php(48): locate_template(Array, true, true, Array) #39 /html/wordpress/wp-content/themes/bricks/template-parts/builder.php(2): get_header() #40 /html/wordpress/wp-includes/template-loader.php(106): include('...') #41 /html/wordpress/wp-blog-header.php(19): require_once('...') #42 /html/wordpress/index.php(17): require('...') #43 {main} thrown in /html/wordpress/wp-content/themes/bricks/includes/elements/base.php on line 1843

My Workaround was to repair the db item manually, which is no option on my client’s production page.
FYI:
I’ve run an update command against wp_postmeta → meta_value which fixed the issue in my case (works only for my specific db entry!):

UPDATE wp_postmeta 
SET meta_value = REPLACE(
    meta_value,
    '"name";s:3:"div"',
    '"name";s:5:"image"'
) 
WHERE post_id = 17
AND meta_key = '_bricks_page_content_2'
AND meta_value LIKE '%"id";s:6:"xuszci"%';

So any ideas/advices about that?
I can’t let my client run into this on a later production page.

Thanks for any advice.

Hi Lars,
Thanks so much for your report!

Unfortunately, I cannot reproduce the problem. Would you please provide a screencast (jam.dev) showing the specific steps to replicate the issue? Thank you!

Best regards,
timmse

Hi @timmse,

unfortunately i can’t provide a screencast because i had to fix the error urgently.
In order to that, i can’t give it a try to run into it, as I don’t have time in this current project to break the development page again.

Best,
Lars

Please take some time and reproduce it on try.bricksbuilder.io, or a different temporary installation.
As long as we don’t know how to reproduce it, we can’t fix it :cry:

I’ve tried to reproduce it on try.bricksbuilder.io but with no success yet. will give it a longer try later.

1 Like