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

Widgets: Social Icons - Missing argument for enqueue_admin_scripts callback when Page Builder (by SiteOrigin) is installed #9234

Closed
oskosk opened this issue Apr 4, 2018 · 18 comments · Fixed by #9236
Labels
[Feature] Extra Sidebar Widgets [Pri] BLOCKER [Type] Bug When a feature is broken and / or not performing as intended

Comments

@oskosk
Copy link
Contributor

oskosk commented Apr 4, 2018

I created a fresh site with Jetpack 6.0, connected it, added Page Builder and when attempting to add a new page I saw these warnings in the log

Undefined variable: hook
 Type: PHP Notice Line: 48
 File: wp-content/plugins/jetpack/modules/widgets/social-icons.php

Missing argument 1 for Jetpack_Widget_Social_Icons::enqueue_admin_scripts(), 
called in wp-content/plugins/siteorigin-panels/inc/admin.php on line 449 and defined

Steps to reproduce the issue

  • On a connected site with Jetpack 6.0 and Page Builder installed.
  • Make sure WP_DEBUG and/or WP_DEBUG_LOG are turned on
  • Attempt to create a new Page ( Pages -> Add New )
  • Check the logs.
  • Expect to see the warning

What I expected

  • No warnings

What happened instead

  • Those warnings
@oskosk oskosk added the [Type] Bug When a feature is broken and / or not performing as intended label Apr 4, 2018
@oskosk oskosk changed the title Social Icons: Missing argument for enqueue_admin_scripts callback Social Icons: Missing argument for enqueue_admin_scripts callback when Site Builder (by SiteOrigin) is installed Apr 4, 2018
@oskosk oskosk changed the title Social Icons: Missing argument for enqueue_admin_scripts callback when Site Builder (by SiteOrigin) is installed Widgets: Social Icons - Missing argument for enqueue_admin_scripts callback when Site Builder (by SiteOrigin) is installed Apr 4, 2018
@jeherve
Copy link
Member

jeherve commented Apr 4, 2018

@jeherve
Copy link
Member

jeherve commented Apr 4, 2018

Also in 1064342-zen

@jeherve jeherve added this to the 6.0.1 milestone Apr 4, 2018
@Automattic Automattic deleted a comment from chaselivingston Apr 4, 2018
@tmmbecker
Copy link

@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

@jeherve I couldn't reproduce anything heavier than this warning. I actually found this warning when trying to reproduce a comment that someone left on the Release post.

@vinnie2k
Copy link

vinnie2k commented Apr 4, 2018

Here is my log of the error breaking the Edit page (fatal error):

Fatal error: Uncaught ArgumentCountError: Too few arguments to function Jetpack_Widget_Social_Icons::enqueue_admin_scripts(), 0 passed in /home//public_html/test/wp-content/plugins/siteorigin-panels/inc/admin.php on line 449 and exactly 1 expected in /home//public_html/test/wp-content/plugins/jetpack/modules/widgets/social-icons.php:45 Stack trace: #0 /home//public_html/test/wp-content/plugins/siteorigin-panels/inc/admin.php(449): Jetpack_Widget_Social_Icons->enqueue_admin_scripts() #1 /home//public_html/test/wp-includes/class-wp-hook.php(286): SiteOrigin_Panels_Admin->enqueue_admin_scripts('') #2 /home//public_html/test/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #3 /home//public_html/test/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #4 /home//public_html/test/wp-admin/admin-header.php(118): do_action('admin_print_scr...') #5 /home//public_html/test/wp-admin/edit-form-advanced.php(483): require_once('/home//...') # in /home//public_html/test/wp-content/plugins/jetpack/modules/widgets/social-icons.php on line 45

@oskosk oskosk changed the title Widgets: Social Icons - Missing argument for enqueue_admin_scripts callback when Site Builder (by SiteOrigin) is installed Widgets: Social Icons - Missing argument for enqueue_admin_scripts callback when Page Builder (by SiteOrigin) is installed Apr 4, 2018
@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

Here's a screenshot of the bigger problem coming from this issue that happens when the Social Icons Widget is indeed present on any sidebar and WP is running on PHP 7.1 or PHP 7.2:

To reproduce:

  • Same steps described in this issue
  • Add a Social Icons widget to a sidebar. No extra configuration needed.

image

@chaselivingston
Copy link
Contributor

Also reported in 423088-hc

@DarrenBatesLLC
Copy link

Having the same issue. I had to DEACTIVATE PAGEBUILDER and ALL SiteOrgin plugins in order to be able to add/edit posts/page and customize site.
screenshot-2018-4-4 edit post smart cities library wordpress

@Misplon
Copy link

Misplon commented Apr 4, 2018 via email

@DarrenBatesLLC
Copy link

DarrenBatesLLC commented Apr 4, 2018 via email

@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

Seems like the problem is generated when Page builder tries to call the enqueue_admin_scripts() method on all widgets available if the method exists. It does not pass any argument to that method call.

Given that some of the widgets may want to take advantage of the $hook parameter (like social icons) and use this class method to be a callback for the admin_enqueue_scripts WordPress action, this fails as a Fatal Error on PHP 7.1 and PHP 7.2

cc @Misplon .

@Misplon
Copy link

Misplon commented Apr 4, 2018

@oskosk SiteOrigin is working the issue. Testing fix at the moment.

@DarrenBatesLLC You can use: https://wordpress.org/plugins/wp-rollback/. (This isn't the best place for support though.)

@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

Thanks for the heads-up @Misplon !

By looking at the conflicting code here: https://github.com/Automattic/jetpack/blob/master/modules/widgets/social-icons.php#L48

...It seems that even if SiteOrigin updates its behaviour then this widget won't show up properly there because we're trying to scope down the pages where we will be loading the supporting js for the widget form.

There's an "Add Icon" button on the Social Icons widget form. Which is supposed to behave like this:

socialiconwidget

But then, by testing with updating the Social Icons Widget enqueue_admin_scripts method signature to be function enqueue_admin_scripts( $hook = null ) so to not throw a fatal, I get to see, that the widget form shows broken in PageBuilder:

socialiconwidget2

@zinigor @jeherve what do you think about this ?

@Misplon
Copy link

Misplon commented Apr 4, 2018

We’re going to release a fix to prevent the fatal error. Basically, just not calling that function for anything that isn’t a core WP JS widget.

Existing JP widgets not using the new front end admin JS way of doing things should still work as before.

We’d love to have new Jetpack widgets working in Page Builder. In order to do that, we’d need a generic way to enqueue the required front end admin scripts.

@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

Thanks @Misplon!

Looks like there was at least one other Jetpack widget that wasn't working properly with Page Builder (The Twitter Timeline widget) because it also checks if we're on the widgets/customizer page before enqueuing JS. This one didn't conflict because the callback it uses for admin_enqueue_scripts is named admin_scripts so Page Builder didn't attempt to call it

@Misplon
Copy link

Misplon commented Apr 4, 2018

Awesome, thanks for your effort and the update, it's most appreciated.

@oskosk
Copy link
Contributor Author

oskosk commented Apr 4, 2018

SiteOrigin has just release version 2.6.4 of Page Builder, addressing issues like the one reported here.

Unfortunately, the fix makes the Social Icons widget not be fully configurable if done through Page Builder.

Props to @Misplon for such a rapid reponse.

I'm closing this issue now.

@oskosk oskosk closed this as completed Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extra Sidebar Widgets [Pri] BLOCKER [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
7 participants