diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
old mode 100644
new mode 100755
index 53f4b31d33..373d3436e3
a
|
b
|
function wp_ajax_replyto_comment( $action ) { |
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | $comment_id = wp_new_comment( $commentdata ); |
| 1103 | |
| 1104 | if ( is_wp_error( $comment_id ) ) { |
| 1105 | wp_die( $comment_id->get_error_message() ); |
| 1106 | } |
| 1107 | |
1103 | 1108 | $comment = get_comment($comment_id); |
1104 | 1109 | if ( ! $comment ) wp_die( 1 ); |
1105 | 1110 | |
diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
old mode 100644
new mode 100755
index 52d2d4e807..c35498cd97
a
|
b
|
class wp_xmlrpc_server extends IXR_Server { |
6487 | 6487 | |
6488 | 6488 | $comment_ID = wp_new_comment($commentdata); |
6489 | 6489 | |
| 6490 | if ( is_wp_error( $comment_ID ) ) { |
| 6491 | return $this->pingback_error( 0, $comment_ID->get_error_message() ); |
| 6492 | } |
| 6493 | |
6490 | 6494 | /** |
6491 | 6495 | * Fires after a post pingback has been sent. |
6492 | 6496 | * |
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
old mode 100644
new mode 100755
index eae3a80731..07fed8100e
a
|
b
|
function wp_allow_comment( $commentdata, $avoid_die = false ) { |
769 | 769 | * Filters a comment's approval status before it is set. |
770 | 770 | * |
771 | 771 | * @since 2.1.0 |
| 772 | * @since 4.9.0 Returning a WP_Error value from the filter will shortcircuit comment insertion and |
| 773 | * allow skipping further processing. |
772 | 774 | * |
773 | | * @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'. |
774 | | * @param array $commentdata Comment data. |
| 775 | * @param bool|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam' or WP_Error. |
| 776 | * @param array $commentdata Comment data. |
775 | 777 | */ |
776 | 778 | $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); |
777 | 779 | return $approved; |
diff --git a/src/wp-trackback.php b/src/wp-trackback.php
old mode 100644
new mode 100755
index 86e17b965d..802bb2ba6d
a
|
b
|
if ( !empty($tb_url) && !empty($title) ) { |
126 | 126 | |
127 | 127 | $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type'); |
128 | 128 | |
129 | | wp_new_comment($commentdata); |
| 129 | $result = wp_new_comment( $commentdata ); |
| 130 | |
| 131 | if ( is_wp_error( $result ) ) { |
| 132 | trackback_response( 1, $result->get_error_message() ); |
| 133 | } |
| 134 | |
130 | 135 | $trackback_id = $wpdb->insert_id; |
131 | 136 | |
132 | 137 | /** |
diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php
old mode 100644
new mode 100755
index 33a0650472..7a8660b913
a
|
b
|
class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { |
222 | 222 | } |
223 | 223 | return $sql; |
224 | 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Raises WP_Error after Posted a new pre comment |
| 228 | * @ticket 39730 |
| 229 | * @return void |
| 230 | */ |
| 231 | public function test_pre_comments_approved () { |
| 232 | |
| 233 | // Become an administrator |
| 234 | $this->_setRole( 'administrator' ); |
| 235 | |
| 236 | // Set up a default request |
| 237 | $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' ); |
| 238 | $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; |
| 239 | $_POST['comment_post_ID'] = self::$comment_post->ID; |
| 240 | |
| 241 | // Simulate filter check error |
| 242 | add_filter( 'pre_comment_approved', array( $this, '_pre_comment_approved_filter' ), 10, 2 ); |
| 243 | |
| 244 | // Make the request |
| 245 | $this->setExpectedException( 'WPAjaxDieStopException', 'pre_comment_approved filter fails for new comment' ); |
| 246 | $this->_handleAjax( 'replyto-comment' ); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Block comments from being saved 'pre_comment_approved', by returning WP_Error |
| 251 | */ |
| 252 | function _pre_comment_approved_filter ( $approved, $commentdata ) { |
| 253 | return new WP_Error( 'comment_wrong', 'pre_comment_approved filter fails for new comment', 403 ); |
| 254 | } |
225 | 255 | } |