Make WordPress Core

Ticket #12431: 12431.diff

File 12431.diff, 1.3 KB (added by wonderboymusic, 10 years ago)
  • src/wp-includes/comment-functions.php

     
    14191419        }
    14201420        $comment = get_comment( $id );
    14211421
     1422        // If metadata is provided metadata, store it now that we know the comment ID
     1423        if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) {
     1424                foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) {
     1425                        add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true );
     1426                }
     1427        }
     1428
    14221429        /**
    14231430         * Fires immediately after a comment is inserted into the database.
    14241431         *
  • tests/phpunit/tests/comment.php

     
    273273                $sent = wp_new_comment_notify_postauthor( $c );
    274274                $this->assertFalse( $sent );
    275275        }
     276
     277        /**
     278         * @ticket 12431
     279         */
     280        public function test_wp_new_comment_with_meta() {
     281                $c = $this->factory->comment->create( array(
     282                        'comment_approved' => '1',
     283                        'comment_meta' => array(
     284                                'food' => 'taco',
     285                                'sauce' => 'fire'
     286                        )
     287                ) );
     288
     289                $this->assertEquals( 'fire', get_comment_meta( $c, 'sauce', true ) );
     290        }
    276291}