Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-admin/includes/ms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why isn't this being caught in the if ( $drop && ! $blog ) check just before it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, that's a good question. The issue this was solving was that $blog wasn't an object.

See: https://travis-ci.org/WordPress/wordpress-develop/jobs/445966625#L1411

I think that there is a chance we aren't setting the environment up completely correctly and that could be causing this.

$drop = false;
}

Expand Down
8 changes: 6 additions & 2 deletions src/wp-includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
25 changes: 25 additions & 0 deletions tests/phpunit/tests/menu/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}