-
-
Notifications
You must be signed in to change notification settings - Fork 278
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] Menu throws Fatal Error #168
Comments
Can you show us the code for how you create your menu? |
I'm using the starter Timber theme and stock Wordpress. I'm customizing my Wordpress site and adding a menu, which causes the error to occure. |
Hi @MrFortnite1111 , I tried to reproduce your issue but are not able to do so with Timber 2.3.0, and the development version of timber starter. I created a menu which does get loaded normally. Have you created any menu locations or done any code changes in your theme? |
I have not made any code changes, but I have made menu locations such as draft/sample pages. No matter what menu location I would add to the menu, it would still give me the fatal error. |
Can you share a minimal git repo and steps on how to configure the database to recreate this specific issue? Without it we can't do much unfortunately. The functionality you mentioned @MrFortnite1111 is covered by unit tests, so the basic functionality is fully tested. Can be that you have a unique situation but we need something on how to test this. |
Hey, so my professor helped me with the issue today and we figured something in the database was corrupted. We exported the code over to a new database and the issue wasn't there anymore. Regardless, thanks for the help along the way to solve the issue. |
So you used Timber at school @MrFortnite1111, that is so nice to hear! Also glad that you were able to solve this issue with some help. Database related issues are always the hardest to debug in WordPress, but luckily don't happen that often. I had one yesterday as well with a website that took me a few hours as well to get running again. Either way, good luck with your project! |
We are still running into this issue throughout the class. Based on what I can see is causing it is when the students are adding a new menu item or deleting the default menu and adding a new menu. It starts getting into this error. Only want to fix it is completely delete the menu from the Customize section of wordpress. But then it holds on to it somehow in wordpress. I believe it may be a wordpress bug right now not saving the menu data correctly in the "Customize" panel. |
Hi @webdobe , welcome! It might be the case that an empty menu causes issues in Normally you would use |
@timber/rangers , it seems that using
I can take care of the first one in the starter theme, the second one will probably be a breaking change and thus can be addressed in Timber 3.x, if agreed I can put that on the board. |
@Levdbas thank you, that is what I observed as well while debugging the issue. I think short term we can just set the get_menu like you mentioned. I think it would be worth mentioning in the docs. Especially if someone starts developing with Timber on an existing wordpress database where they have modified the menus. |
Moved the issue to the starter theme. The changes to fix this are in place, we just need to do some final checks on the code and release a new version if we don't want to iterate on this further for now. @gchtr , after the holidays, shall we take a look at this? |
@Levdbas Sounds good! |
Expected Behavior
No Fatal Error
Actual behavior
Fatal error: Uncaught InvalidArgumentException: Expected an instance of Timber\CoreInterface or WP_Term, got stdClass in /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Factory/MenuFactory.php:172 Stack trace: #0 /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Factory/MenuFactory.php(76): Timber\Factory\MenuFactory->from_object(Object(stdClass), Array) timber/timber#1 /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Factory/MenuFactory.php(33): Timber\Factory\MenuFactory->from_nav_menu_terms(Array) timber/timber#2 /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Timber.php(995): Timber\Factory\MenuFactory->from(NULL, Array) timber/timber#3 /var/www/html/wordpress/wp-content/themes/hampteraptor/src/StarterSite.php(44): Timber\Timber::get_menu() timber/timber#4 /var/www/html/wordpress/wp-includes/class-wp-hook.php(324): StarterSite->add_to_context(Array) timber/timber#5 /var/www/html/wordpress/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) timber/timber#6 /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Timber.php(1315): apply_filters('timber/context', Array) timber/timber#7 /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Timber.php(1206): Timber\Timber::context_global() timber/timber#8 /var/www/html/wordpress/wp-content/themes/hampteraptor/page.php(24): Timber\Timber::context() timber/timber#9 /var/www/html/wordpress/wp-includes/template-loader.php(106): include('/var/www/html/w...') timber/timber#10 /var/www/html/wordpress/wp-blog-header.php(19): require_once('/var/www/html/w...') timber/timber#11 /var/www/html/wordpress/index.php(17): require('/var/www/html/w...') timber/timber#12 {main} thrown in /var/www/html/wordpress/wp-content/themes/hampteraptor/vendor/timber/timber/src/Factory/MenuFactory.php on line 172
Steps to reproduce behavior
Any time I create a menu it throws this fatal error.
Notes
No response
What version of Timber are you using?
2.x-dev
What version of WordPress are you using?
6.6.2
What version of PHP are you using?
8.1
How did you install Timber?
Installed or updated Timber through Composer
The text was updated successfully, but these errors were encountered: