Make WordPress Core


Ignore:
Timestamp:
07/15/2019 06:24:08 AM (6 years ago)
Author:
pento
Message:

Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.

PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

Props jrf.
See #47704.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r45427 r45639  
    478478    public function filter_wp_get_nav_menu_items( $items, $menu, $args ) {
    479479        $this_item                = $this->value();
    480         $current_nav_menu_term_id = $this_item['nav_menu_term_id'];
    481         unset( $this_item['nav_menu_term_id'] );
     480        $current_nav_menu_term_id = null;
     481        if ( isset( $this_item['nav_menu_term_id'] ) ) {
     482            $current_nav_menu_term_id = $this_item['nav_menu_term_id'];
     483            unset( $this_item['nav_menu_term_id'] );
     484        }
    482485
    483486        $should_filter = (
     
    494497            false === $this_item
    495498            ||
    496             true === $this_item['_invalid']
     499            ( isset( $this_item['_invalid'] ) && true === $this_item['_invalid'] )
    497500            ||
    498501            (
Note: See TracChangeset for help on using the changeset viewer.