Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#36784 closed enhancement (fixed)

wp_update_comment should work with meta

Reported by: dshanske's profile dshanske Owned by: dshanske's profile dshanske
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.4
Component: Comments Keywords: has-patch early has-unit-tests
Focuses: Cc:

Description

Since 4.4, wp_insert_comment allows you to pass through meta that will be added to the new comment...

    // If metadata is provided, store it.
    if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) {
        foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) {
            add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true );
        }
    }

I have found this very useful in simplifying my new comment construction.

Suggesting the same code be added to wp_update_comment, except using update_comment_meta, to mirror the functionality.

Attachments (5)

36784.diff (740 bytes) - added by dshanske 8 years ago.
36784.2.diff (710 bytes) - added by dshanske 8 years ago.
Didn't look closely.
36784.3.diff (2.4 KB) - added by dshanske 8 years ago.
Add Unit Tests
36784.4.diff (1.5 KB) - added by boonebgorges 8 years ago.
36784.5.diff (2.0 KB) - added by kraftbj 7 years ago.
Refresh and add @since

Download all attachments as: .zip

Change History (28)

@dshanske
8 years ago

@dshanske
8 years ago

Didn't look closely.

This ticket was mentioned in Slack in #core-comments by dshanske. View the logs.


8 years ago

#2 @voldemortensen
8 years ago

  • Keywords has-patch early added
  • Milestone changed from Awaiting Review to Future Release

@dshanske
8 years ago

Add Unit Tests

#3 @dshanske
8 years ago

  • Keywords has-unit-tests added

@boonebgorges
8 years ago

#4 @boonebgorges
8 years ago

36784.4.diff refreshes 36784.3.diff with the following:

  • Remove unnecessary changes to whitespace in $keys array
  • Improve code formatting and remove excess whitespace in test

I think we also need a @since annotation for this, too. See https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#since-section-changelogs

Functionality and test look pretty good. Let's do this for 4.7.

This ticket was mentioned in Slack in #core-comments by dshanske. View the logs.


8 years ago

#6 @rachelbaker
8 years ago

  • Keywords 4.7-early added

#7 @rachelbaker
8 years ago

I agree with @boonebgorges, will be considered for 4.7

This ticket was mentioned in Slack in #core by helen. View the logs.


8 years ago

#9 @helen
8 years ago

  • Milestone changed from Future Release to 4.7

Sounds like patch needs an update but otherwise milestoning so it doesn't get lost.

#10 @jorbin
7 years ago

@rachelbaker @boonebgorges Still hope to do this for 4.7? What remains to be done?

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


7 years ago

#12 @rachelbaker
7 years ago

  • Keywords 4.7-early removed
  • Milestone changed from 4.7 to Future Release

We missed the early part of the 4.7 release cycle, so I am punting out of the 4.7 milestone. If this ticket does start picking up momentum we can move it back.

#13 @dshanske
7 years ago

Is there a problem other than the @since?

This ticket was mentioned in Slack in #core by dshanske. View the logs.


7 years ago

#15 @dshanske
7 years ago

Wanted to update the notation on the ticket. @rachelbaker clarified it is a change in functionality to a common function and may bring up unexpected edge cases.

Will bring this up for 4.8-early later on.

#16 @dshanske
7 years ago

  • Milestone changed from Future Release to 4.8

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

#19 @rachelbaker
7 years ago

  • Milestone changed from 4.8 to Future Release

Punted to Future Release, since this missed the first Beta of 4.8.

#20 @dshanske
7 years ago

Considering this was tagged originally for 4.7-early...how can I prevent it from being punted again?

#21 @dshanske
7 years ago

  • Milestone changed from Future Release to 4.9

To my knowledge, other than the concern re behavior, nothing needs to be done. Tests are included, @boonebgorges made modifications to my original patch.

#22 @kraftbj
7 years ago

  • Owner set to dshanske
  • Status changed from new to assigned

+1 to 4.9 and should land it early for plenty of time to marinate. Refreshing patch and adding @since 4.9.0 to note new ability.

@kraftbj
7 years ago

Refresh and add @since

#23 @boonebgorges
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 40981:

Allow metadata to be updated via wp_update_comment().

Passing an array of comment_meta into wp_update_comment() will
now update corresponding metadata. Similar functionality already
exists in wp_insert_comment().

Props dshanske, kraftbj.
Fixes #36784.

Note: See TracTickets for help on using tickets.