Community Forums › Forums › Archived Forums › Design Tips and Tricks › 500 error on 5.0 upgrade caused by Genesis calls in mu-plugin
Tagged: 500 error, mu-plugin, plugin, upgrade, Wordpress 5.0
- This topic has 2 replies, 2 voices, and was last updated 5 years, 9 months ago by codeshim.
-
AuthorPosts
-
December 7, 2018 at 12:32 pm #224887codeshimParticipant
Hey all,
Posted this question in the WordPress forums and was told "those are all Genesis-specific function calls", go ask at Studiopress. So here I am! 🙂I found a way around this, so this is more of a why did this happen/best practices question.
I experienced a 500 error during upgrade to WordPress 5.0. It affected only the backend/admin area; the front end was still accessible. This happened first in local dev environment/Valet, but repeated itself in other hosting environments. During troubleshooting, I found that disabling the following specific lines of widgets-init code in my site specific mu-plugin fixed the problem:
function tm_genesis_emc_widgets() { genesis_register_sidebar( array( 'id' => 'get_quote', 'name' => __( 'EMC Get Quote area', 'genesischild' ), 'description' => __( 'Adds HTML to last menu item', 'genesischild' ), ) ); genesis_register_sidebar( array( 'id' => 'woodgrain_social', 'name' => __( 'EMC Woodgrain Social area', 'genesischild' ), 'description' => __( 'Adds HTML to bar under front page 1 area', 'genesischild' ), ) ); genesis_register_sidebar( array( 'id' => 'menu_page_sidebar', 'name' => __( 'Menu Page Floating Sidebar', 'genesischild' ), 'description' => __( 'Adds an overlay sidebar area to Menu page', 'genesischild' ), ) ); } add_action( 'widgets_init', 'tm_genesis_emc_widgets' );
If I comment out this section of code, the upgrade runs as expected. If I uncomment this code after upgrade, everything continues to run as expected.
Can anyone help me understand why this caused a 500 error during upgrade, and what I should have done differently to prevent it and make my code more robust?
I have updated WordPress core many times before with this mu-plugin activated, but the 5.0 update was the first time this happened.
All plugins and themes are at latest versions. Disabling all other plugins (besides the mu-plugin) did not fix the problem. Genesis theme is at latest version.
Any thoughts? Thanks!
December 7, 2018 at 1:12 pm #224889Victor FontModeratorFirst, thanks for posting, but this forum is a community volunteer forum. Please understand that by posting here you're not asking StudioPress anything. We're end users just like you with no affiliation with StudioPress. To ask StudioPress a question, you have to go through their support channel.
The error you experienced is most likely a timing issue. A 500 error is non-descript and can be caused by many different problems. Knowing exactly which one is often not possible.
I say timing, because during the upgrade, the Genesis Framework probably wasn't fully loaded yet when widgets_init tried to call genesis_register_sidebar. WordPress loads themes after plugins. By using that code as a plugin, you probably triggered a timing mismatch.
If that were my plugin, I would put a check in it to make sure the genesis() function exists before calling the genesis_register_sidebar function. This way if genesis hasn't fully loaded yet, you can return out of it without any issue.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?December 7, 2018 at 1:18 pm #224890codeshimParticipantVictor, thanks for your input!
Using that check is a great idea; I'll add that. I also think next time I will place code that uses Genesis functions into the child theme's functions.php file instead. I was already using the mu-plugin for other customizations and just added my code there for convenience, but since it depends on the Genesis theme being active, it's probably better placed in the child theme anyway.
-
AuthorPosts
- The topic ‘500 error on 5.0 upgrade caused by Genesis calls in mu-plugin’ is closed to new replies.