WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/14/2018 05:15:54 AM (16 months ago)
Author:
desrosj
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/nav-menu.php

    r43571 r44167  
    11871187
    11881188                // ...actually match!
    1189                 if ( false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) {
     1189                if ( is_string( $new_location ) && false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) {
     1190                    continue;
     1191                } elseif ( is_numeric( $new_location ) && $new_location !== $slug ) {
    11901192                    continue;
    11911193                }
     
    11981200
    11991201                        // ... have a match as well.
    1200                         if ( false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) {
     1202                        if ( is_string( $location ) && false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) {
     1203                            continue;
     1204                        } elseif ( is_numeric( $location ) && $location !== $slug ) {
    12011205                            continue;
    12021206                        }
Note: See TracChangeset for help on using the changeset viewer.