NO BUG: Nested slider options sanitization error

Nested slider sanitize object using stripslashes.
That occurs an error.
This error occurs when image used into slider is replaced by another plugin named Enable Media Replace (By ShortPixel).
But this is not this plugin problem.
Problem is object sanitization.

  1. Create nested slider.
  2. Add image to slide and save.
  3. Display page with slider.
  4. Replace image into Media Library using Enable Media Replace plugin (use the same image You upload earlier).
  5. Refresh page with slider.
  6. Error will display.

I use custom slider options:

{
  "type": "slide",
  "autoplay": false,
  "speed": 400,
  "perPage": 1,
  "perMove": 1,
  "gap": 15,
  "pagination": true,
  "reducedMotion": {
    "autoplay": "pause",
    "speed": 400,
    "rewindSpeed": 400
  },
  "breakpoints": {
    "576": {
      "perPage": 1,
      "perMove": 1
    },
    "768": {
      "perPage": 1,
      "perMove": 1
    },
    "992": {
      "perPage": 1,
      "perMove": 1
    },
    "1200": {
      "perPage": 1,
      "perMove": 1
    }
  }
}
Fatal error: Uncaught TypeError: stripslashes(): Argument #1 ($string) must be of type string, stdClass given in /public_html/wp-content/themes/bricks/includes/elements/slider-nested.php:1324

This part of code occurs problem with object sanitization.

trim( stripslashes( $settings['options'] )

Stripslashes function is executing on object:

object(stdClass)#28077 (9) {
  ["type"]=>
  string(5) "slide"
  ["autoplay"]=>
  bool(false)
  ["speed"]=>
  int(400)
  ["perPage"]=>
  int(1)
  ["perMove"]=>
  int(1)
  ["gap"]=>
  int(15)
  ["pagination"]=>
  bool(true)
  ["reducedMotion"]=>
  object(stdClass)#26352 (3) {
    ["autoplay"]=>
    string(5) "pause"
    ["speed"]=>
    int(400)
    ["rewindSpeed"]=>
    int(400)
  }
  ["breakpoints"]=>
  object(stdClass)#28080 (4) {
    ["576"]=>
    object(stdClass)#26012 (2) {
      ["perPage"]=>
      int(1)
      ["perMove"]=>
      int(1)
    }
    ["768"]=>
    object(stdClass)#26018 (2) {
      ["perPage"]=>
      int(1)
      ["perMove"]=>
      int(1)
    }
    ["992"]=>
    object(stdClass)#26621 (2) {
      ["perPage"]=>
      int(1)
      ["perMove"]=>
      int(1)
    }
    ["1200"]=>
    object(stdClass)#26620 (2) {
      ["perPage"]=>
      int(1)
      ["perMove"]=>
      int(1)
    }
  }
}

Hi @MarekKmiecik ,

The $settings['options'] should be a pure string.

I just tried your steps, and I can replicate the issue when using the replace media function from the Enable Media Replace plugin.

However, this is not a bug from Bricks. The Bricks post meta was modified by the plugin.

I believe this is their plugin logic:

  • When media is replaced, the plugin queries all meta values from the entire website that contain the replaced media URL/ID. It then performs some replacement logic and updates the meta values.
  • Unfortunately, their replacement logic causes Bricks data stored in _bricks_page_content_2 to become corrupted. The string is converted to an object, resulting in the PHP error you encountered.

You can experiment with this to prove that this issue is not related to Bricks. Here are the steps:

  1. Create a nested slider using your custom options.

  2. Add an image to the slide and save.

  3. Get a copy of the _bricks_page_content_2 value from the postmeta table where post_id is equal to your slider page. You should be able to see your saved data like this:

  4. Switch the theme to the default WP theme (Twenty Twenty-Four).

  5. Replace the image in the Media Library using the Enable Media Replace plugin (use the same image you uploaded earlier).

  6. Check the meta_value again; it should be converted like this by the plugin:

As you can see, during the replacement process, the logic that updates the meta_value is controlled by the Enable Media Replace plugin.

Hence, I would suggest you reach out to their support to solve this issue.

I hope this explanation makes sense.

Regards,
Jenn

1 Like

Now I know, the Eneble Media Replace plugin broke post_meta (_bricks_page_content_2).
I hope, the plugin developer remove this issue.

In this moment I recommend Easy Replace Image plugin.
This plugin replace only image, not post meta, and don’t broke pages or other content build with Bricks Builder.

Hello @itchycode ,

I just had the same problem. Thanks to this thread for giving me a solution.