diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 220d6323e3562..4c0668494ec66 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -98,7 +98,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { } // Don't destroy the initial, main, or root blog. - if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) { + if ( $drop && $blog && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) { $drop = false; } diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 6a290bdaa9e31..74214c6636440 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -1139,7 +1139,9 @@ function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locat foreach ( $registered_nav_menus as $new_location => $name ) { // ...actually match! - if ( false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) { + if ( is_string( $new_location ) && false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) { + continue; + } elseif ( is_numeric( $new_location ) && $new_location !== $slug ) { continue; } @@ -1150,7 +1152,9 @@ function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locat foreach ( $slug_group as $slug ) { // ... have a match as well. - if ( false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) { + if ( is_string( $location ) && false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) { + continue; + } elseif ( is_numeric( $location ) && $location !== $slug ) { continue; } diff --git a/tests/phpunit/tests/menu/nav-menu.php b/tests/phpunit/tests/menu/nav-menu.php index b0da967b8b9a3..d8fbd6b92fee9 100644 --- a/tests/phpunit/tests/menu/nav-menu.php +++ b/tests/phpunit/tests/menu/nav-menu.php @@ -200,4 +200,29 @@ function test_numerical_locations() { ); $this->assertEqualSets( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } + + /** + * Technically possible old nav menu locations were registered numerically. + * + * @covers wp_map_nav_menu_locations() + */ + public function test_numerical_old_locations() { + $this->register_nav_menu_locations( array( 'primary', 1 ) ); + + $old_nav_menu_locations = array( + 'primary' => 1, + 'tertiary' => 2, + 0 => 3, + ); + + $next_theme_nav_menu_locations = array(); + $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $next_theme_nav_menu_locations, $old_nav_menu_locations ); + + $expected_nav_menu_locations = array( + 'primary' => 1, + 0 => 3, + ); + + $this->assertEqualSets( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + } }