Nav Menus: Fix a PHP 7.3 error when switching themes.

When switching themes, `wp_map_nav_menu_locations()` is used to ensure nav menus are placed in the relevant menu location. Occasionally, menus are registered to locations with numeric slugs, rather than strings. `wp_map_nav_menu_locations()` assumed it would be the latter, and ran `stripos()` on those numeric slugs. This behavior is deprecated in PHP 7.3.

As this is the last PHP 7.3 error in unit tests, this commit also removes PHP 7.3 from Travis' `allowed_failures` list.

Props pento, desrosj, jorbin.

Merges [43899] to trunk.

See #45018.
Built from https://develop.svn.wordpress.org/trunk@44167


git-svn-id: http://core.svn.wordpress.org/trunk@43997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2018-12-14 05:16:52 +00:00
parent 268402cf53
commit 7cb9a98a5b
2 changed files with 7 additions and 3 deletions

View File

@ -1186,7 +1186,9 @@ function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locat
foreach ( $registered_nav_menus as $new_location => $name ) { foreach ( $registered_nav_menus as $new_location => $name ) {
// ...actually match! // ...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; continue;
} }
@ -1197,7 +1199,9 @@ function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locat
foreach ( $slug_group as $slug ) { foreach ( $slug_group as $slug ) {
// ... have a match as well. // ... 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; continue;
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44166'; $wp_version = '5.1-alpha-44167';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.