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

React to any errors coming up in gutenberg_migrate_menu_to_navigation_post #36461

Merged
merged 3 commits into from
Nov 13, 2021

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented Nov 13, 2021

As @spacedmonkey mentioned in a review of the navigation areas PR, migrating menu locations to navigation areas on theme switch, wp_insert_post may fail and return WP_Error instance. This must be handled somehow, and I propose to just short-circuit the entire migration. There isn't a fully functional mapping available, so I'd rather abort than set a half-baked one.

Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for handling this. Looks good.

I left a suggestion around comments and also a query.

@@ -280,7 +284,7 @@ function gutenberg_migrate_menu_to_navigation_post( $new_name, $new_theme, $old_
update_option( 'fse_navigation_areas', $area_mapping );
}

add_action( 'switch_theme', 'gutenberg_migrate_menu_to_navigation_post', 200, 3 );
add_action( 'switch_theme', 'gutenberg_migrate_menu_to_navigation_post', 99, 3 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we update the ordering here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this change: https://github.com/WordPress/wordpress-develop/pull/1865/files#diff-4112a9a0bb18713bc2fc7868ceffe4403d765722f605e42b313ef2cdc218177fR685

I learned it's more typical to use priority at most 99 in core and that's how it was backported.

lib/navigation.php Outdated Show resolved Hide resolved
Co-authored-by: Dave Smith <getdavemail@gmail.com>
noisysocks pushed a commit that referenced this pull request Nov 15, 2021
…_post (#36461)

* React to any errors coming up in gutenberg_migrate_menu_to_navigation_post

* Lint

* Update lib/navigation.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

Co-authored-by: Dave Smith <getdavemail@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants