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. Built from https://develop.svn.wordpress.org/branches/5.0@43819 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
50ef6331e7
commit
9635ac49bb
|
@ -633,6 +633,7 @@ class WP_Comment_Query {
|
|||
$number = absint( $this->query_vars['number'] );
|
||||
$offset = absint( $this->query_vars['offset'] );
|
||||
$paged = absint( $this->query_vars['paged'] );
|
||||
$limits = '';
|
||||
|
||||
if ( ! empty( $number ) ) {
|
||||
if ( $offset ) {
|
||||
|
@ -818,6 +819,7 @@ class WP_Comment_Query {
|
|||
}
|
||||
|
||||
$join = '';
|
||||
$groupby = '';
|
||||
|
||||
if ( $join_posts_table ) {
|
||||
$join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
|
||||
|
|
|
@ -3517,6 +3517,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'wp.editComment' );
|
||||
$comment = array(
|
||||
'comment_ID' => $comment_ID,
|
||||
);
|
||||
|
||||
|
||||
if ( isset($content_struct['status']) ) {
|
||||
$statuses = get_comment_statuses();
|
||||
|
@ -3524,31 +3528,33 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
if ( ! in_array($content_struct['status'], $statuses) )
|
||||
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
|
||||
$comment_approved = $content_struct['status'];
|
||||
$comment['comment_approved'] = $content_struct['status'];
|
||||
}
|
||||
|
||||
// Do some timestamp voodoo
|
||||
if ( !empty( $content_struct['date_created_gmt'] ) ) {
|
||||
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
|
||||
|
||||
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
|
||||
$comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
|
||||
$comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
|
||||
$comment['comment_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
|
||||
$comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
|
||||
}
|
||||
|
||||
if ( isset($content_struct['content']) )
|
||||
$comment_content = $content_struct['content'];
|
||||
if ( isset($content_struct['content']) ) {
|
||||
$comment['comment_content'] = $content_struct['content'];
|
||||
}
|
||||
|
||||
if ( isset($content_struct['author']) )
|
||||
$comment_author = $content_struct['author'];
|
||||
if ( isset($content_struct['author']) ) {
|
||||
$comment['comment_author'] = $content_struct['author'];
|
||||
}
|
||||
|
||||
if ( isset($content_struct['author_url']) )
|
||||
$comment_author_url = $content_struct['author_url'];
|
||||
if ( isset($content_struct['author_url']) ) {
|
||||
$comment['comment_author_url'] = $content_struct['author_url'];
|
||||
}
|
||||
|
||||
if ( isset($content_struct['author_email']) )
|
||||
$comment_author_email = $content_struct['author_email'];
|
||||
|
||||
// We've got all the data -- post it:
|
||||
$comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url');
|
||||
if ( isset($content_struct['author_email']) ) {
|
||||
$comment['comment_author_email'] = $content_struct['author_email'];
|
||||
}
|
||||
|
||||
$result = wp_update_comment($comment);
|
||||
if ( is_wp_error( $result ) )
|
||||
|
@ -4989,16 +4995,25 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$post_name = $content_struct['wp_slug'];
|
||||
|
||||
// Only use a password if one was given.
|
||||
if ( isset($content_struct['wp_password']) )
|
||||
if ( isset($content_struct['wp_password']) ) {
|
||||
$post_password = $content_struct['wp_password'];
|
||||
} else {
|
||||
$post_password = '';
|
||||
}
|
||||
|
||||
// Only set a post parent if one was provided.
|
||||
if ( isset($content_struct['wp_page_parent_id']) )
|
||||
if ( isset($content_struct['wp_page_parent_id']) ) {
|
||||
$post_parent = $content_struct['wp_page_parent_id'];
|
||||
} else {
|
||||
$post_parent = 0;
|
||||
}
|
||||
|
||||
// Only set the menu_order if it was provided.
|
||||
if ( isset($content_struct['wp_page_order']) )
|
||||
if ( isset($content_struct['wp_page_order']) ) {
|
||||
$menu_order = $content_struct['wp_page_order'];
|
||||
} else {
|
||||
$menu_order = 0;
|
||||
}
|
||||
|
||||
$post_author = $user->ID;
|
||||
|
||||
|
@ -5316,6 +5331,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$post_parent = $postdata['post_parent'];
|
||||
$post_type = $postdata['post_type'];
|
||||
$menu_order = $postdata['menu_order'];
|
||||
$ping_status = $postdata['ping_status'];
|
||||
$comment_status = $postdata['comment_status'];
|
||||
|
||||
// Let WordPress manage slug if none was provided.
|
||||
$post_name = $postdata['post_name'];
|
||||
|
|
|
@ -2965,7 +2965,7 @@ function _close_comments_for_old_post( $open, $post_id ) {
|
|||
*/
|
||||
function wp_handle_comment_submission( $comment_data ) {
|
||||
|
||||
$comment_post_ID = $comment_parent = 0;
|
||||
$comment_post_ID = $comment_parent = $user_ID = 0;
|
||||
$comment_author = $comment_author_email = $comment_author_url = $comment_content = null;
|
||||
|
||||
if ( isset( $comment_data['comment_post_ID'] ) ) {
|
||||
|
|
|
@ -3415,6 +3415,13 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
|||
$post_parent = 0;
|
||||
}
|
||||
|
||||
$new_postarr = array_merge(
|
||||
array(
|
||||
'ID' => $post_ID,
|
||||
),
|
||||
compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the post parent -- used to check for and prevent hierarchy loops.
|
||||
*
|
||||
|
@ -3425,7 +3432,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
|||
* @param array $new_postarr Array of parsed post data.
|
||||
* @param array $postarr Array of sanitized, but otherwise unmodified post data.
|
||||
*/
|
||||
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
|
||||
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );
|
||||
|
||||
/*
|
||||
* If the post is being untrashed and it has a desired slug stored in post meta,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-43818';
|
||||
$wp_version = '5.0-alpha-43819';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue