From 80dd8b9b8377616bf8ff0e4632945ac94e2b127d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 15 Nov 2018 23:20:48 +0000 Subject: [PATCH] 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 behaviour is deprecated in PHP 7.3. As this is the last known PHP 7.3 incompatibility, this commit also removes PHP 7.3 from Travis' `allowed_failures` list. Props desrosj, jorbin. See #45018. Built from https://develop.svn.wordpress.org/branches/5.0@43899 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43731 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 6a290bdaa9..74214c6636 100644 --- a/wp-includes/nav-menu.php +++ b/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/wp-includes/version.php b/wp-includes/version.php index bfc267b8dc..134d56fcf9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-beta4-43898'; +$wp_version = '5.0-beta4-43899'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.