From c7ca1870db8e836c366a2caf716071ff5fe48300 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 15 Nov 2021 22:45:52 +1100 Subject: [PATCH] Changes from lib/navigation.php --- src/wp-includes/navigation-areas.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/navigation-areas.php b/src/wp-includes/navigation-areas.php index 9107c52fa94cc..5d946973bb802 100644 --- a/src/wp-includes/navigation-areas.php +++ b/src/wp-includes/navigation-areas.php @@ -123,7 +123,12 @@ function _wp_migrate_menu_to_navigation_post( $new_name, WP_Theme $new_theme, WP 'post_content' => serialize_blocks( $parsed_blocks ), 'post_status' => 'publish', ); - $navigation_post_id = wp_insert_post( $post_data ); + $navigation_post_id = wp_insert_post( $post_data, true ); + // If wp_insert_post fails *at any time*, then bail out of the + // entire migration attempt returning the WP_Error object. + if ( is_wp_error( $navigation_post_id ) ) { + return $navigation_post_id; + } } $area_mapping[ $location_name ] = $navigation_post_id;