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/meta.php

    r45590 r45639  
    524524    if ( ! $meta_cache ) {
    525525        $meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
    526         $meta_cache = $meta_cache[ $object_id ];
     526        if ( isset( $meta_cache[ $object_id ] ) ) {
     527            $meta_cache = $meta_cache[ $object_id ];
     528        } else {
     529            $meta_cache = null;
     530        }
    527531    }
    528532
Note: See TracChangeset for help on using the changeset viewer.