Make WordPress Core

Ticket #39730: 39730.3.patch

File 39730.3.patch, 2.8 KB (added by enrico.sorcinelli, 8 years ago)

Updated to the current trunk.

  • src/wp-admin/includes/ajax-actions.php

     
    11001100        }
    11011101
    11021102        $comment_id = wp_new_comment( $commentdata );
     1103
     1104        if ( is_wp_error( $comment_id ) ) {
     1105                wp_die ( $comment_id->get_error_message() );
     1106        }
     1107
    11031108        $comment = get_comment($comment_id);
    11041109        if ( ! $comment ) wp_die( 1 );
    11051110
  • tests/phpunit/tests/ajax/ReplytoComment.php

     
    222222                }
    223223                return $sql;
    224224        }
     225
     226        /**
     227         * @ticket 39730
     228         */
     229        public function test_pre_comments_approved () {
     230               
     231                // Become an administrator
     232                $this->_setRole( 'administrator' );
     233
     234                // Set up a default request
     235                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
     236                $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     237                $_POST['comment_post_ID']             = self::$comment_post->ID;
     238
     239                // Simulate filter check error
     240                add_filter ( 'pre_comment_approved', array( $this, '_pre_comment_approved_filter' ), 10, 2 );
     241
     242                // Make the request
     243                $this->setExpectedException( 'WPAjaxDieStopException', 'pre_comment_approved filter fails for new comment' );
     244                $this->_handleAjax( 'replyto-comment' );
     245        }
     246
     247        /**
     248         *  Block comments from being saved 'pre_comment_approved', by returning WP_Error
     249         */
     250        function _pre_comment_approved_filter ( $approved, $commentdata ) {
     251                return new WP_Error( 'comment_wrong', __( 'pre_comment_approved filter fails for new comment' ), 403 );
     252        }
    225253}
  • src/wp-trackback.php

     
    126126
    127127        $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
    128128
    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
    130135        $trackback_id = $wpdb->insert_id;
    131136
    132137        /**
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    65056505
    65066506                $comment_ID = wp_new_comment($commentdata);
    65076507
     6508                if ( is_wp_error( $comment_ID ) ) {
     6509                        return $this->pingback_error( 0, $comment_ID->get_error_message() );
     6510                }
     6511
    65086512                /**
    65096513                 * Fires after a post pingback has been sent.
    65106514                 *