Make WordPress Core


Ignore:
Timestamp:
10/24/2018 04:32:29 PM (6 years ago)
Author:
jorbin
Message:

php7.3 compatibility: Fix compact throwing notices

In PHP 7.3, the compact() function has been changed to issue an E_NOTICE level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. The full RFC can be viewed here: https://wiki.php.net/rfc/compact

This fixes all unit tested code that uses compact.

Props desrosj.
Fixes #44416.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/post.php

    r43806 r43819  
    34163416    }
    34173417
     3418    $new_postarr = array_merge(
     3419        array(
     3420            'ID' => $post_ID,
     3421        ),
     3422        compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
     3423    );
     3424
    34183425    /**
    34193426     * Filters the post parent -- used to check for and prevent hierarchy loops.
     
    34263433     * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
    34273434     */
    3428     $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
     3435    $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );
    34293436
    34303437    /*
Note: See TracChangeset for help on using the changeset viewer.