Improve error handling when converting classic to block menus#52482
Improve error handling when converting classic to block menus#52482dlh01 wants to merge 1 commit intoWordPress:trunkfrom
Conversation
draganescu
left a comment
There was a problem hiding this comment.
These updates make sense to me 🚀
|
|
||
| if ( empty( $menu_items ) ) { | ||
| return array(); | ||
| return ''; |
There was a problem hiding this comment.
Should this return a WP_error object?
There was a problem hiding this comment.
It's also got me thinking. Any changes here will possible effect the fallback handling code so we'd need to check there.
I'd hope if the tests aren't failing it's all ok but it's entirely possible there isn't 100% coverage 🤔
There was a problem hiding this comment.
Actually I don't think this should be an error. That's because we have converted the menu but it was just empty. That doesn't make it invalid. The conversion was a success.
We're just exiting early to avoid running the "to_blocks" code.
Later on we throw an error if the conversion to blocks fails because that's a true "error".
|
@getdave Sure, I think I can do that. Is there anything more to it than filing a core PR with the same changes? |
That would be great. Thank you. Yes you raise a Core PR with the same changes in the equivalent files. And you need a Trac ticket. |
|
Done in https://core.trac.wordpress.org/ticket/58823 and WordPress/wordpress-develop#4858. Thanks! |
|
Looks like the failing PHP tests are related: |
What?
See #52481. Addresses some errors that can occur when
Gutenberg_Navigation_Fallback::create_classic_menu_fallback()callsGutenberg_Classic_To_Block_Menu_Converter::convert().Why?
To avoid unexpected behavior or errors resulting from incorrect type handling.
How?
Improving type-checking and returning types consistent with the documentation