littlebizzy / slickstack

Lightning-fast WordPress on Nginx
https://slickstack.io
GNU General Public License v3.0
643 stars 113 forks source link

SlickStack is interfering with the WordPress Theme Customizer #92

Closed wponramp closed 3 years ago

wponramp commented 3 years ago

Getting a critical error on WordPress when trying to customize any WordPress theme.

jessuppi commented 3 years ago

Hello @wponramp as per your other Issue do you have any error code or anything specific you can share?

Without more information this is not helpful. Do you see errors in /var/www/logs/error.log that might be related to this problem and might narrow down what is causing your problem? It is likely not SlickStack related.

wponramp commented 3 years ago

Here's what I see in the error logs:

10 /var/www/html/wp-includes/class-wp-hook.php(3 in /var/www/html/wp-includes/class-wp-customize-widgets.php on line 1127

9 /var/www/html/wp-includes/class-wp-hook.php(287): WP_Customize_Manager->wp_loaded()

8 /var/www/html/wp-includes/class-wp-customize-manager.php(933): do_action()

7 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action()

6 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()

5 /var/www/html/wp-includes/class-wp-hook.php(287): WP_Customize_Widgets->schedule_customize_register()

4 /var/www/html/wp-includes/class-wp-customize-widgets.php(353): WP_Customize_Widgets->customize_register()

3 /var/www/html/wp-includes/class-wp-customize-widgets.php(376): wp_get_sidebars_widgets()

2 /var/www/html/wp-includes/widgets.php(1023): apply_filters()

1 /var/www/html/wp-includes/plugin.php(212): WP_Hook->apply_filters()

0 /var/www/html/wp-includes/class-wp-hook.php(287): WP_Customize_Widgets->preview_sidebars_widgets()

Stack trace: [24-Feb-2021 15:35:43 UTC] PHP Fatal error: Uncaught Error: Cannot unset string offsets in /var/www/html/wp-includes/class-wp-customize-widgets.php:1127

jessuppi commented 3 years ago

This is getting a bit outside of SlickStack territory I think, but I suggest the following:

  1. Reinstall WordPress Core
  2. Reset all permissions
  3. Disable all your WordPress plugins
  4. Switch to a default WordPress theme like Twenty Twenty
  5. Try to open the customizer again

If the problem disappears than either your WP core files were corrupted or a plugin is causing this issue.

wponramp commented 3 years ago

Thanks for the suggestions. I tried all of them sequentially as recommended and still getting a critical error. I'll take it from here. Thanks again.

skilver-io commented 3 years ago

Hi guys,

I came across the same issue today with a new setup. Also for the Twenty Twenty Theme the issue is not resolved. There was a discussion on this topic on the WordPress support page 8 months ago. It seems to be related to ghost entries in the WP Cron option.

This might help https://wordpress.org/support/topic/fatal-error-uncaught-error-cannot-unset-string-offsets-2/

And another related discussion here https://wordpress.org/support/topic/invalid-empty-cron-events/

@jessuppi Is this error related to slickstack?

@wponramp Have you been able to resolve the issue?

jessuppi commented 3 years ago

@skilver-io Thanks for the information,

There are quite possibly erroneous entries in WP Cron caused by our default MU plugins, some of which have not been updated in a long while (and have some incomplete features, that we plan to abandon).

That being said, it seems strange that an invalid cron job could cause WordPress Core to malfunction. I haven't had time to dig into this further but if anyone has more feedback please comment here.

skilver-io commented 3 years ago

I was trying to dig a bit deeper into the issue today.

However I did some testing and came across the following findings on a fresh SS install:

  1. Theme customizer is only working for the twenty twenty theme. All other default WP themes (e.g. twenty tenty one etc.) will throw an error in the theme customizer.

  2. I deactivated all MU plugins step by step starting with the MU_PLUGIN_19 back up to the top in the ss-config file. The error for the theme customizer persists. Therefore I assume no issues with the MU plugins. However, there is one other issues I came across here: When I commented out the last MU_PLUGIN_01, all plugins will be installed again after running sudo bash /var/www/ss-install-wordpress-mu-plugins. Not sure if this is intended.

  3. When installing a new theme, permissions are set to Chmod 644 (-rw-r--r--) for all php files within the single theme's folder. I'd assume the correct permission would be Chmod 744. However the twenty twenty theme also has the same 0644 permissions and the themes customizer works. I believe WP would also show an error message regarding a higher permission level needed if this would be the source of error.

@jessuppi I would love to help more but I am just not experienced enough in this matter. That's why I started using your slickstack in the first place =)

Is there any chance this helps to solve the issue quickly?

skilver-io commented 3 years ago

I could resolve the issue by the help of nakitai from the SS Discord channel.

nakitai: ..slickstack has a plugin that deletes things like pages menus and widgets you would otherwise find in a fresh wordpress installation. However, some themes require these to work properly so before entering customizer make sure to have a dummy page, post, menu and a widget active.

jessuppi commented 3 years ago

I appreciate the research and follow-up posts @skilver-io

Based on your findings I have commented out the Throwaway Theme we had been adding by default (for now).

Ref: https://github.com/littlebizzy/slickstack/commit/df281911813901b7ee80aaefcec514b108111035

We had been planning to delete it anyways and convert some of the "cleanup" functions to basic Bash scripting, but based on this I will probably change it to avoid deleting the demo content in the new version...

jessuppi commented 3 years ago

Just an update that SlickStack no longer installs a "throwaway" WordPress theme (ever), and instead some of the wp_options cleanup now happens in the ss-install-wordpress-core script instead:

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-install-wordpress-core.txt

This lightweight "cleanup" of wp_options should only happen on virgin installs, where ss-install-wordpress-core has never been run before (e.g. the timestamp file does not exist). I will also add an option in ss-config to disable this functionality for anyone who doesn't want this to occur (I will follow up again).

Going forward, we won't delete any "demo" content from fresh WordPress installs to keep things more standard.

jessuppi commented 3 years ago

There is now a new option in ss-config called SS_INSTALL_WORDPRESS_CORE_CLEANUP_OPTIONS ... set it to false if you don't want ss-install-wordpress-core to cleanup your options table for virgin installs.

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-config-sample.txt