Make WordPress Core


Ignore:
Timestamp:
12/14/2018 05:12:12 AM (6 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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • 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.
Note: See TracChangeset for help on using the changeset viewer.