elementor/elementor

[BUG] Argument #1 is not an array in /base/controls-stack.php on line 1184

zeinnicholas opened this issue ยท 46 comments

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest stable version of Elementor.

Description

Users have been reporting errors with WooCommerce based websites after updating to 2.9.2:

Warning: array_merge(): Argument #1 is not an array in .../wp-content/plugins/elementor/includes/base/controls-stack.php on line 1184

It has something to do with Dynamic Tags and the use of the Custom Add To Cart button inside static pages.

Update:

It seems that this issue is not related only to WooCommerce and the Custom Add To Cart Button, so it's imperative to test the Dynamic Tags being used regardless if WC is installed or not.

This page: https://docs.elementor.com/article/620-known-bugs-of-elementor does not reflect the entire issue.

As originally divulged when the button was added to the list of widgets, it's meant to be used anywhere on the entire site, not only on WC pages, so the link above is wrong and it shouldn't suggest that this is a user error (e.g: "[...] or you have a Custom Add to Cart widget on a page that is not a WC template."). As in the documentation, the description states clearly that the button is allowed to be used on the entire site:

image
See: https://docs.elementor.com/article/536-custom-add-to-cart

For more information about the issues:

https://www.facebook.com/groups/Elementors/search/?query=argument%20%231&epa=SEARCH_BOX

Steps to reproduce

WooCommerce environment:

  1. Add the Custom Add To Cart button to the homepage.

It may only happen upon updating from a previous Elementor version to the new one.

Isolating the problem

  • This bug happens with only Elementor plugin active (and Elementor Pro).
  • This bug happens with a default WordPress theme active.
  • I can reproduce this bug consistently using the steps above.

Thanks, we are currently working on this issue and will update this thread when there's an update.

I'm also receiving the same error after the latest update but I don't have Woocommerce installed on my site. The error code only appears on a certain custom post type single template in the section containing a Taxonomy Terms List widget from a 3rd party plugin (Dynamic Content for Elementor)

I (also) noticed the same error in a third party plugin (LifterElements) after updating to 2.9.1.

In my case, the error seems to happen when using the "update_control" method on a widget.

For what I saw, the error happens only if I change the type of a control.

For example, this will result to the error:

$control = $element->get_controls( $name );
$control['type'] = \Elementor\Controls_Manager::HIDDEN;
$element->update_control( $name, $control );

But this will not:

$control = $element->get_controls( $section_id );
$control['conditions'] = [
  'terms' => [
    [
      'name' => 'render_type',
      'operator' => 'in',
      'value' => [ 'custom_button'],
    ],
  ]
];
$element->update_control( $section_id, $control );

I hope it will help!

Hi,
Since last update i am getting same error with a plugin "Photo Gallery" from Web10.
The gallery is diplayed correctly but i get an error message displayed above the gallery and in the header section.
the message says:
Warning: array_merge(): Expected parameter 1 to be an array, bool given in /homepages/20/d516795946/htdocs/clickandbuilds/LesGlotteTrotters/wp-content/plugins/elementor/includes/base/controls-stack.php on line 1184
I have deactivated the plugin, the message desapear but it comes back when i reactivate it.
I have updated all to latest version, clean cache but still gettin this message!
Every thing was OK with versions prior to 2.9.0. I am now 2.9.2 and PRO 2.8.4
Thank you
PS: Ticket openned on support site

Hi, I had the same issue after installing the latest version of WP and Elementor. Once I activated SSL, the problem was gone. May this helps you, too?

This seems to be a problem for many users across the board and with my current traffic and use cases of my plugins I would rather not do the test of deactivating plugins.

What is the latest guys?

Same problem. Changing:

$dynamic_settings = array_merge( $dynamic_settings, $control['dynamic'] );
to
$dynamic_settings = array_merge( wp_parse_id_list( $dynamic_settings ), $control['dynamic'] );

Solves the issue, but introduces other problems. Update appreciated.

I have this issue with Woocommerce and the Custom Add To Cart button using the Theme Builder for a Single Product Page. It consistenly occurs everywhere i add the button this page. I should add that i do not set a product to the button leaving it to "All Products" so that it dynamically implies add the current product to the cart.

I updated the original issue to reflect the various reports about this happening regardless of the usage of the Custom Add To Cart Button or WooCommerce.

Also, the link for the search about the issue in the Elementor Group only shows posts that copied and pasted the Warning in the post body, but it's actually also being reported with images. Far beyond the number of posts originally reported.

This Problem is due to merge of array and non array variables in php 7.3 and above as per my experience.

Kindly change at Line 1183.

if ( ! empty( $control['dynamic'] ) {

to

if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {

Solves the issue...

@zenstars, just tried what you suggest and it fixes the issue.
Thank you very much!

Hi All.

I am new to github and I am not an advanced coder, but I understand the basics. I do more design based work.

As Jimyaghi stated above, I am also getting this error when using the Custom Add to Card button in Elementor Pro. We use WooCommerce.

Warning: array_merge(): Argument #1 is not an array in /home/cathil49/public_html/smartfit.rocks/wp-content/plugins/elementor/includes/base/controls-stack.php on line 1184

here is the page link.

Has there been a patch or update yet?

@mikevendia It looks like the issue has been fixed in this commit (on the dev branch). I guess we need to wait for the next Elementor version for having the fix now.

lczz commented

This Problem is due to merge of array and non array variables in php 7.3 and above as per my experience.

Kindly change at Line 1183.

if ( ! empty( $control['dynamic'] ) {

to

if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {

Solves the issue...

It worked, thanks!

Worked for me, thanks.

sabuz commented

Not fixed in latest version! I tried on PHP 7.3

Elementor update 2.9.3 is fixing the issue on my side, thanks

Elementor update 2.9.3 fixed on my side as well. Thanks, Elementor Team.

I tried upgrade to 2.9.3 and problem is still there. Tried disable all plugins and problem remains.

@sabuz and @jwales88 can you please elaborate on your issues? Where is it appearing? What are you using for it to appear? Maybe share your System Info log.

Iczz posted the fix above that worked for me - per Elementor v2.9.3 / PHP 7.0 - issue only appeared on my home page, not on any other post or page.

FIX:
EDIT /wp-content/plugins/elementor/includes/base/controls-stack.php

This Problem is due to merge of array and non array variables in php 7.3 and above as per my experience.

Kindly change at Line 1183.
if ( ! empty( $control['dynamic'] ) {
to
if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {

Solves the issue...

I updated Elementor to version 2.9.3 but the issue still exists. It appears only when I use the Airi Element widget "aTheme: Blog".

I am not a programmer. I only add posts to our foundation's website using elementor so I basically have no idea how to solve this and why is this happening. I hope you can help @zeinnicholas

here is the link to one of the pages that shows the bug.
https://beshns.com/when-friends-meet-hearts-warm/

pau-panda28 - you will need to pass the above info to someone (webmaster/developer) that has access to the file system via FTP or cPanel FileManager, etc. in order to edit the file causing the issue.

For me it's only happening on the home page here: (http://wisconsinfan.com)

Iczz posted the fix above that worked for me - per Elementor v2.9.3 / PHP 7.0 - issue only appeared on my home page, not on any other post or page.

FIX:
EDIT /wp-content/plugins/elementor/includes/base/controls-stack.php

This Problem is due to merge of array and non array variables in php 7.3 and above as per my experience.

Kindly change at Line 1183.
if ( ! empty( $control['dynamic'] ) {
to
if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {

Solves the issue...

Rock and roll indeed it does! Thanks!

The problem is not solved yet.
I get the same error. I use a plugin https://wordpress.org/plugins/drozd-addons-for-elementor/ Info Box widget.
Previously, all widgets worked fine, and after updating Elementor 2.9.3, the warning: array_merge(): Expected parameter 1 to be an array, null given in error began to appear ...wp-content\plugins\elementor\includes\base\controls-stack.php on line 1184

Fixed this.

I updated Elementor to version 2.9.3 but the issue still exists. It appears only when I use the Airi Element widget "aTheme: Blog".

I am not a programmer. I only add posts to our foundation's website using elementor so I basically have no idea how to solve this and why is this happening. I hope you can help @zeinnicholas

here is the link to one of the pages that shows the bug.
https://beshns.com/when-friends-meet-hearts-warm/

@pau-panda28 In your case I strongly suggest you contact the 3rd party developer of that widget to ask him to fix it, since there is another way to accomplish that widget functionality that isn't dependant on the Dynamic functionality that is causing the issue.

@shilo-ey it seems the issue persists after 2.9.3. Maybe applying the fix from @zenstars above would fix the issue for everyone?

@zeinnicholas commented on Feb 28, 2020, 4:33 PM GMT+2:

@shilo-ey it seems the issue persists after 2.9.3. Maybe applying the fix from @zenstars above would fix the issue for everyone?

We will take a look and update you. Thanks!

@shilo-ey Hi. When will you fix the error?

I checked in version 2.9.2 of Elementor there is no error, and in version 2.9.3 the error appeared.

Or tell us what plugin developers need to change in their plugins so that there is no error?

Can you give a link to the page where you specify your changes so that the developers know what needs to be fixed?

Thanks.

I removed this code from the widgets that showed the error and the error does not appear.

'dynamic' => [ 'active' => true, ],

This code is no longer used at all? I looked at the documentation examples, you removed this code from all the examples. I'm talking about these examples https://developers.elementor.com/elementor-controls/

Dear All,

One thing I need to clear, that with my earlier fix and update to elementor 2.9.3, I did not have any error. If anyone has the same error after update to the elementor 2.9.3, please remove my fix and change line 1183 of wp-content\plugins\elementor\includes\base\controls-stack.php back to the original as mentioned below...

if ( ! empty( $control['dynamic'] ) ) {

Thanks...

@zenstars When updating the Elementor to 2.9.3, the code will update itself and you do not need to manually delete it. But in version 2.9.3 the problem is not solved.

@UrchenkoV What kind of error user have after update to ver 2.9.3.

For further read : https://stackoverflow.com/questions/20131948/php-array-merge-if-not-empty

@zenstars ...wp-content\plugins\elementor\includes\base\controls-stack.php on line 1184

@UrchenkoV Please change on line 1184

$dynamic_settings = array_merge( (array)$dynamic_settings, $control['dynamic'] );

This will force to convert $dynamic_settings variable to an array which removes array merge error.

This Problem is due to merge of array and non array variables in php 7.3 and above as per my experience.

Kindly change at Line 1183.

if ( ! empty( $control['dynamic'] ) {

to

if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {

Solves the issue...

it's working 100%
great ๐Ÿ˜Š๐Ÿ˜Š๐Ÿ˜Š

@zenstars Thanks. I did this, it solves the problem, but this method is suitable for site owners and I am a plugin developer.

People install the plugin and it should work correctly, not show errors.

The Elementor command should solve this problem.

I solved this problem for the plugin like this: I removed this code 'dynamic' = > ['active' = > true,], from the widgets that showed the error.

This issue has been resolved in Elementor v2.9.4

Feel free to update

Thanks!

Just updated, everything is OK, thank you

Thank you so much! Cheers!

I am facing this issue with "wordpress": "5.4.2", "elementor":"2.9.13" and "essential-addons-for-elementor-lite":"4.0.2"

I am facing this issue with "wordpress": "5.4.2", "elementor":"2.9.13" and "essential-addons-for-elementor-lite":"4.0.2"

@geekodour If you are having this issue only with an addon enabled, it means your addon is conflicting with Elementor. Contact the addon support so they can fix their conflict. If this issue persists with only Elementor and Elementor Pro enabled, then create a new issue, since this one was already closed, but remember to mention this one.

Hi, I still getting the error.
After we put the site live, then used the Replace Url in elementor tool, this error show up. Any one knows why is this show up? I thought it was fixed on the last update. Thanks

Hi, I still getting the error.
After we put the site live, then used the Replace Url in elementor tool, this error show up. Any one knows why is this show up? I thought it was fixed on the last update. Thanks

@Heysoulnat can you please elaborate? Maybe share your Dashboard > Elementor > System Info?

how use this cord please help me
if ( ! empty( $control['dynamic'] ) {
to
if ( ! empty( $control['dynamic'] ) && is_array($dynamic_settings)) {