WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#38202 closed enhancement (fixed)

Allow post object or post id for ping functions

Reported by: dshanske Owned by: pento
Milestone: 4.7 Priority: low
Severity: minor Version:
Component: Pings/Trackbacks Keywords: has-patch has-unit-tests dev-feedback commit
Focuses: Cc:

Description

Suggesting the following functions be updated to accept either a post_ID or a post object

get_pung( int $post_id )
get_to_ping( int $post_id )
do_trackbacks( int $post_id )

Attachments (3)

38202.diff (7.0 KB) - added by dshanske 4 years ago.
Add Post Object support to Ping Functions
38202.2.diff (9.6 KB) - added by dshanske 4 years ago.
Adds some unit tests
38202.3.diff (9.4 KB) - added by dshanske 4 years ago.
Fixes

Download all attachments as: .zip

Change History (23)

@dshanske
4 years ago

Add Post Object support to Ping Functions

#1 @dshanske
4 years ago

  • Keywords has-patch added; good-first-bug needs-patch removed

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


4 years ago

#3 @swissspidy
4 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 4.7

Patch looks good, sounds like a great opportunity to add some unit tests though.

#4 follow-up: @pento
4 years ago

The @since comment on do_trackbacks() is incomplete.

What's the purpose of making this change?

#5 @dshanske
4 years ago

To support optimization of do_all_pings

#6 in reply to: ↑ 4 @swissspidy
4 years ago

Replying to pento:

What's the purpose of making this change?

Most functions in core support poth post objects and IDs nowdays. I especially like that we can get rid of $wpdb in get_to_ping() that way.

#7 @dshanske
4 years ago

I could use some help with the unit tests. It's something I'm still struggling to learn how to write.

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


4 years ago

@dshanske
4 years ago

Adds some unit tests

#9 @dshanske
4 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Owner set to dshanske
  • Status changed from new to assigned

#10 @dshanske
4 years ago

Added unit tests for the changes to get_to_ping, get_pung, add_ping.

Not sure how to test trackback and pingback sending. I think that is out of scope for this.

#11 @rachelbaker
4 years ago

@dshanske the functions still accept a post_id, so let's keep the parameter name as $post_id.

#12 @rachelbaker
4 years ago

  • Keywords needs-refresh added

#13 @dshanske
4 years ago

Happy to make the change. I thought changing the parameter name to post made it more consistent with other functions that work similarly. But it isn't an issue either way.

#14 @dshanske
4 years ago

In pingack it is post_ID, in the others post_id. In the interest of consistency, I changed all of them to post_id.

@dshanske
4 years ago

Fixes

#15 @dshanske
4 years ago

  • Keywords needs-refresh removed

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


4 years ago

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


4 years ago

#18 @dshanske
4 years ago

  • Keywords dev-feedback commit added

#19 @pento
4 years ago

  • Owner changed from dshanske to pento
  • Status changed from assigned to reviewing

#20 @pento
4 years ago

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

In 38852:

Pings: Allow ping functions to accept WP_Post objects as well as post IDs.

This removes the use of several global $wpdb instances, as well as bringing the ping functions into line with other post-related functions, which will accept a post ID or WP_Post object.

Props dshanke.
Fixes #38202.

Note: See TracTickets for help on using tickets.