Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 of 5 tasks
zeinnicholas opened this issue Feb 17, 2020 · 46 comments
Closed
4 of 5 tasks
Labels
bug Indicates a bug with one or multiple components. status/merged Indicates when a Pull Request has been merged to a Release.

Comments

@zeinnicholas
Copy link

zeinnicholas commented Feb 17, 2020

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.
@shilo-ey shilo-ey added the bug Indicates a bug with one or multiple components. label Feb 17, 2020
@shilo-ey
Copy link
Contributor

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

@Windurin
Copy link

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)

@nicolas-jaussaud
Copy link

nicolas-jaussaud commented Feb 18, 2020

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!

@GerardPerret
Copy link

GerardPerret commented Feb 18, 2020

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

@peerfalk
Copy link

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?

@gocryptowise
Copy link

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?

@idkdevsa
Copy link

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.

@jimyaghi
Copy link

jimyaghi commented Feb 20, 2020

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.

@zeinnicholas
Copy link
Author

zeinnicholas commented Feb 21, 2020

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.

@zenstars
Copy link

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...

@GerardPerret
Copy link

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

@shilo-ey shilo-ey added the status/merged Indicates when a Pull Request has been merged to a Release. label Feb 24, 2020
@mikevendia
Copy link

mikevendia commented Feb 25, 2020

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?

@nicolas-jaussaud
Copy link

@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
Copy link

lczz commented Feb 26, 2020

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!

@michlcamp
Copy link

Worked for me, thanks.

@sabuz
Copy link

sabuz commented Feb 27, 2020

Not fixed in latest version! I tried on PHP 7.3

@GerardPerret
Copy link

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

@mikevendia
Copy link

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

@jwales88
Copy link

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

@zeinnicholas
Copy link
Author

@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.

@michlcamp
Copy link

michlcamp commented Feb 28, 2020

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...

@pau-panda28
Copy link

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/

@michlcamp
Copy link

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.

@jwales88
Copy link

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

@jwales88
Copy link

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!

@UrchenkoV
Copy link

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.

@zeinnicholas
Copy link
Author

zeinnicholas commented Feb 28, 2020

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.

@zeinnicholas
Copy link
Author

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

@shilo-ey
Copy link
Contributor

@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!

@UrchenkoV
Copy link

@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.

@UrchenkoV
Copy link

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/

@zenstars
Copy link

zenstars commented Mar 2, 2020

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...

@UrchenkoV
Copy link

@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.

@zenstars
Copy link

zenstars commented Mar 2, 2020

@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

@UrchenkoV
Copy link

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

@zenstars
Copy link

zenstars commented Mar 2, 2020

@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.

@auntusaha
Copy link

auntusaha commented Mar 3, 2020

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 😊😊😊

@UrchenkoV
Copy link

@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.

@shilo-ey
Copy link
Contributor

shilo-ey commented Mar 4, 2020

This issue has been resolved in Elementor v2.9.4

Feel free to update

Thanks!

@GerardPerret
Copy link

Just updated, everything is OK, thank you

@zeinnicholas
Copy link
Author

Thank you so much! Cheers!

@geekodour
Copy link

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

@zeinnicholas
Copy link
Author

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.

@Heysoulnat
Copy link

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

@zeinnicholas
Copy link
Author

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?

@Sorafuddin221
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates a bug with one or multiple components. status/merged Indicates when a Pull Request has been merged to a Release.
Projects
None yet
Development

No branches or pull requests