Make WordPress Core

Changeset 44166


Ignore:
Timestamp:
12/14/2018 05:12:12 AM (8 years ago)
Author:
desrosj
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.

Props jorbin, desrosj.

Merges [43819] and [43832] to trunk.

Fixes #44416.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/class-wp-comment-query.php

    r42875 r44166  
    636636                $offset = absint( $this->query_vars['offset'] );
    637637                $paged  = absint( $this->query_vars['paged'] );
     638                $limits = '';
    638639
    639640                if ( ! empty( $number ) ) {
     
    820821                }
    821822
    822                 $join = '';
     823                $join    = '';
     824                $groupby = '';
    823825
    824826                if ( $join_posts_table ) {
  • trunk/src/wp-includes/class-wp-network-query.php

    r42876 r44166  
    328328                $number = absint( $this->query_vars['number'] );
    329329                $offset = absint( $this->query_vars['offset'] );
     330                $limits = '';
    330331
    331332                if ( ! empty( $number ) ) {
     
    392393
    393394                $where = implode( ' AND ', $this->sql_clauses['where'] );
     395
     396                $groupby = '';
    394397
    395398                $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
  • trunk/src/wp-includes/class-wp-site-query.php

    r43010 r44166  
    421421                $number = absint( $this->query_vars['number'] );
    422422                $offset = absint( $this->query_vars['offset'] );
     423                $limits = '';
    423424
    424425                if ( ! empty( $number ) ) {
     
    585586                $where = implode( ' AND ', $this->sql_clauses['where'] );
    586587
     588                $groupby = '';
     589
    587590                $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
    588591
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r43571 r44166  
    37003700                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    37013701                do_action( 'xmlrpc_call', 'wp.editComment' );
     3702                $comment = array(
     3703                        'comment_ID' => $comment_ID,
     3704                );
    37023705
    37033706                if ( isset( $content_struct['status'] ) ) {
     
    37083711                                return new IXR_Error( 401, __( 'Invalid comment status.' ) );
    37093712                        }
    3710                         $comment_approved = $content_struct['status'];
     3713
     3714                        $comment['comment_approved'] = $content_struct['status'];
    37113715                }
    37123716
     
    37143718                if ( ! empty( $content_struct['date_created_gmt'] ) ) {
    37153719                        // We know this is supposed to be GMT, so we're going to slap that Z on there by force
    3716                         $dateCreated      = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
    3717                         $comment_date     = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
    3718                         $comment_date_gmt = iso8601_to_datetime( $dateCreated, 'GMT' );
     3720                        $dateCreated                 = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
     3721                        $comment['comment_date']     = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
     3722                        $comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
    37193723                }
    37203724
    37213725                if ( isset( $content_struct['content'] ) ) {
    3722                         $comment_content = $content_struct['content'];
     3726                        $comment['comment_content'] = $content_struct['content'];
    37233727                }
    37243728
    37253729                if ( isset( $content_struct['author'] ) ) {
    3726                         $comment_author = $content_struct['author'];
     3730                        $comment['comment_author'] = $content_struct['author'];
    37273731                }
    37283732
    37293733                if ( isset( $content_struct['author_url'] ) ) {
    3730                         $comment_author_url = $content_struct['author_url'];
     3734                        $comment['comment_author_url'] = $content_struct['author_url'];
    37313735                }
    37323736
    37333737                if ( isset( $content_struct['author_email'] ) ) {
    3734                         $comment_author_email = $content_struct['author_email'];
    3735                 }
    3736 
    3737                 // We've got all the data -- post it:
    3738                 $comment = compact( 'comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url' );
     3738                        $comment['comment_author_email'] = $content_struct['author_email'];
     3739                }
    37393740
    37403741                $result = wp_update_comment( $comment );
     
    52625263                if ( isset( $content_struct['wp_password'] ) ) {
    52635264                        $post_password = $content_struct['wp_password'];
     5265                } else {
     5266                        $post_password = '';
    52645267                }
    52655268
     
    52675270                if ( isset( $content_struct['wp_page_parent_id'] ) ) {
    52685271                        $post_parent = $content_struct['wp_page_parent_id'];
     5272                } else {
     5273                        $post_parent = 0;
    52695274                }
    52705275
     
    52725277                if ( isset( $content_struct['wp_page_order'] ) ) {
    52735278                        $menu_order = $content_struct['wp_page_order'];
     5279                } else {
     5280                        $menu_order = 0;
    52745281                }
    52755282
     
    56005607                $this->escape( $postdata );
    56015608
    5602                 $ID            = $postdata['ID'];
    5603                 $post_content  = $postdata['post_content'];
    5604                 $post_title    = $postdata['post_title'];
    5605                 $post_excerpt  = $postdata['post_excerpt'];
    5606                 $post_password = $postdata['post_password'];
    5607                 $post_parent   = $postdata['post_parent'];
    5608                 $post_type     = $postdata['post_type'];
    5609                 $menu_order    = $postdata['menu_order'];
     5609                $ID             = $postdata['ID'];
     5610                $post_content   = $postdata['post_content'];
     5611                $post_title     = $postdata['post_title'];
     5612                $post_excerpt   = $postdata['post_excerpt'];
     5613                $post_password  = $postdata['post_password'];
     5614                $post_parent    = $postdata['post_parent'];
     5615                $post_type      = $postdata['post_type'];
     5616                $menu_order     = $postdata['menu_order'];
     5617                $ping_status    = $postdata['ping_status'];
     5618                $comment_status = $postdata['comment_status'];
    56105619
    56115620                // Let WordPress manage slug if none was provided.
  • trunk/src/wp-includes/comment.php

    r43982 r44166  
    30833083function wp_handle_comment_submission( $comment_data ) {
    30843084
    3085         $comment_post_ID = $comment_parent = 0;
     3085        $comment_post_ID = $comment_parent = $user_ID = 0;
    30863086        $comment_author  = $comment_author_email = $comment_author_url = $comment_content = null;
    30873087
  • trunk/src/wp-includes/post.php

    r44150 r44166  
    36033603        }
    36043604
     3605        $new_postarr = array_merge(
     3606                array(
     3607                        'ID' => $post_ID,
     3608                ),
     3609                compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
     3610        );
     3611
    36053612        /**
    36063613         * Filters the post parent -- used to check for and prevent hierarchy loops.
     
    36133620         * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
    36143621         */
    3615         $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
     3622        $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );
    36163623
    36173624        /*
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r44115 r44166  
    868868         */
    869869        public function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() {
     870                $file                   = '';
    870871                $wp_enqueue_code_editor = wp_enqueue_code_editor( compact( 'file' ) );
    871872                $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r44154 r44166  
    50875087        "date": "2017-02-14T00:00:00",
    50885088        "date_gmt": "2017-02-14T00:00:00",
    5089         "id": 3162,
     5089        "id": 36744,
    50905090        "modified": "2017-02-14T00:00:00",
    50915091        "modified_gmt": "2017-02-14T00:00:00",
    5092         "parent": 3161,
    5093         "slug": "3161-revision-v1",
     5092        "parent": 36743,
     5093        "slug": "36743-revision-v1",
    50945094        "guid": {
    5095             "rendered": "http://example.org/?p=3162"
     5095            "rendered": "http://example.org/?p=36744"
    50965096        },
    50975097        "title": {
     
    51075107            "parent": [
    51085108                {
    5109                     "href": "http://example.org/index.php?rest_route=/wp/v2/posts/3161"
     5109                    "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36743"
    51105110                }
    51115111            ]
     
    51425142        "date": "2017-02-14T00:00:00",
    51435143        "date_gmt": "2017-02-14T00:00:00",
    5144         "id": 3163,
     5144        "id": 36745,
    51455145        "modified": "2017-02-14T00:00:00",
    51465146        "modified_gmt": "2017-02-14T00:00:00",
    5147         "parent": 3161,
    5148         "slug": "3161-autosave-v1",
     5147        "parent": 36743,
     5148        "slug": "36743-autosave-v1",
    51495149        "guid": {
    5150             "rendered": "http://example.org/?p=3163"
     5150            "rendered": "http://example.org/?p=36745"
    51515151        },
    51525152        "title": {
     
    51625162            "parent": [
    51635163                {
    5164                     "href": "http://example.org/index.php?rest_route=/wp/v2/posts/3161"
     5164                    "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36743"
    51655165                }
    51665166            ]
     
    51735173    "date": "2017-02-14T00:00:00",
    51745174    "date_gmt": "2017-02-14T00:00:00",
    5175     "id": 3163,
     5175    "id": 36745,
    51765176    "modified": "2017-02-14T00:00:00",
    51775177    "modified_gmt": "2017-02-14T00:00:00",
    5178     "parent": 3161,
    5179     "slug": "3161-autosave-v1",
     5178    "parent": 36743,
     5179    "slug": "36743-autosave-v1",
    51805180    "guid": {
    5181         "rendered": "http://example.org/?p=3163"
     5181        "rendered": "http://example.org/?p=36745"
    51825182    },
    51835183    "title": {
     
    53475347        "date": "2017-02-14T00:00:00",
    53485348        "date_gmt": "2017-02-14T00:00:00",
    5349         "id": 3165,
     5349        "id": 36747,
    53505350        "modified": "2017-02-14T00:00:00",
    53515351        "modified_gmt": "2017-02-14T00:00:00",
    5352         "parent": 3164,
    5353         "slug": "3164-revision-v1",
     5352        "parent": 36746,
     5353        "slug": "36746-revision-v1",
    53545354        "guid": {
    5355             "rendered": "http://example.org/?p=3165"
     5355            "rendered": "http://example.org/?p=36747"
    53565356        },
    53575357        "title": {
     
    53675367            "parent": [
    53685368                {
    5369                     "href": "http://example.org/index.php?rest_route=/wp/v2/pages/3164"
     5369                    "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36746"
    53705370                }
    53715371            ]
     
    54025402        "date": "2017-02-14T00:00:00",
    54035403        "date_gmt": "2017-02-14T00:00:00",
    5404         "id": 3166,
     5404        "id": 36748,
    54055405        "modified": "2017-02-14T00:00:00",
    54065406        "modified_gmt": "2017-02-14T00:00:00",
    5407         "parent": 3164,
    5408         "slug": "3164-autosave-v1",
     5407        "parent": 36746,
     5408        "slug": "36746-autosave-v1",
    54095409        "guid": {
    5410             "rendered": "http://example.org/?p=3166"
     5410            "rendered": "http://example.org/?p=36748"
    54115411        },
    54125412        "title": {
     
    54225422            "parent": [
    54235423                {
    5424                     "href": "http://example.org/index.php?rest_route=/wp/v2/pages/3164"
     5424                    "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36746"
    54255425                }
    54265426            ]
     
    54335433    "date": "2017-02-14T00:00:00",
    54345434    "date_gmt": "2017-02-14T00:00:00",
    5435     "id": 3166,
     5435    "id": 36748,
    54365436    "modified": "2017-02-14T00:00:00",
    54375437    "modified_gmt": "2017-02-14T00:00:00",
    5438     "parent": 3164,
    5439     "slug": "3164-autosave-v1",
     5438    "parent": 36746,
     5439    "slug": "36746-autosave-v1",
    54405440    "guid": {
    5441         "rendered": "http://example.org/?p=3166"
     5441        "rendered": "http://example.org/?p=36748"
    54425442    },
    54435443    "title": {
Note: See TracChangeset for help on using the changeset viewer.