Make WordPress Core

Opened 10 years ago

Closed 21 months ago

#38197 closed enhancement (fixed)

Update Pingback function To Add Return

Reported by: dshanske Owned by: flixos90
Priority: normal Milestone: 6.8
Component: Pings/Trackbacks Version:
Severity: normal Keywords: good-first-bug has-patch has-unit-tests commit
Cc: Focuses: performance

Description (last modified by dshanske)

Related to #36824.

Updated to reflect focus on the return issue.

In #36824, the proposal was to improve performance of the do_all_pings function. Part of this involves the fact that if a pending trackback URL is sent a pingback successfully, it should not also send a trackback.

The function should also optionally return which URLs were successfully pinged or a WP_Error object in the event the sending fails, etc.

This would change the signature of the function but would allow for debugging, response to errors, as well as assist in optimizing the do_all_pings function.

The original proposal was to deprecate pingback because it includes $content, a parameter better retrieved from the post itself for purposes of integrity. However, that can be addressed in other ways.

Attachments (2)

38197.diff​ (1.4 KB ) - added by NathanAtmoz 9 years ago.
38197.1.diff​ (1.6 KB ) - added by soulseekah 9 years ago.
refresh + docblock

Download all attachments as: .zip

Change History (53)

#1 @dshanske
10 years ago

  • Description modified (diff)
  • Summary Deprecate and Replace Pingback() Function → Update Pingback function To Add Return

#2 @welcher
10 years ago

  • Keywords needs-patch added

#3 @shulard
10 years ago

Hello !

I'm actually trying to make a patch for that ticket, but can't find a clean way to handle this. The pingback function can ping multiple URLs in one call, how the return value can be consistent with that :

  • Always return an array of found URL as key and true / WP_Error if URL was pinged successfully or not ?
  • Return an array of pinged URL or a WP_Error if at leat one failed ?
Last edited 10 years ago by shulard (previous) (diff)

#4 @dshanske
10 years ago

You are right, handling this is difficult.

My suggestion is to start by splitting the code that sends a single ping based on a URL into a new function with a return. This will get a single true/false to build an array. We can also add split the function to find the content in a content block.

That would allow the existing function to call them but future changes in do_all_pings to call each piece independently.

In the meantime, pingback can return true if all successful, which should shutdown Trackbacks for the post_id.

#5 @NathanAtmoz
9 years ago

The patch attached returns an array with the $pagelinkedto as the key and the result of WP_HTTP_IXR_Client::query() as the key. Not sure if this is a sufficient solution for your needs.

#6 @dshanske
9 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Awaiting Review → 4.9

Needs a second opinion, but I think this is acceptable.

#7 @jbpaul17
9 years ago

  • Keywords 2nd-opinion added

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


9 years ago

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


9 years ago

#10 @jbpaul17
9 years ago

  • Milestone 4.9 → Future Release

Punting this to Future Release per the 4.9 bug scrub earlier today.

#11 @NathanAtmoz
9 years ago

  • Keywords dev-feedback added

#12 @DrewAPicture
9 years ago

  • Owner set to nathanatmoz
  • Status new → assigned

Assigning to mark the good-first-bug as "claimed".

@dshanske Can you please have a look a the patch and provide any feedback @NathanAtmoz might need to keep this ticket moving?

#13 @dshanske
9 years ago

@DrewAPicture I do not see anything wrong with the patch. I asked for a second opinion at the time. It returns an array of statuses, so someone can evaluate whether there was an issue with any of them.

#14 @dshanske
9 years ago

  • Keywords 2nd-opinion removed
  • Milestone Future Release → 4.9.5

#15 @dshanske
9 years ago

#41842 was marked as a duplicate.

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


9 years ago

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


9 years ago

#18 @ocean90
9 years ago

  • Keywords needs-refresh added

The change needs to be ​documented in the function's DocBlock.

#19 @audrasjb
9 years ago

  • Milestone 4.9.5 → 4.9.6

Bumping to 4.9.6 due to 4.9.5 beta release.

@soulseekah
9 years ago

refresh + docblock

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


9 years ago

#21 @soulseekah
9 years ago

  • Keywords needs-refresh removed

#22 @desrosj
9 years ago

I am inclined to punt this to 5.0 because the function signature is changing.

#23 @dshanske
9 years ago

@desrosj I don't think the signature has changed. The arguments passed are the same. There was no return, now there is.

I think if functionality changes in a non-backward compatible way, that is a signature change. If you add a parameter or return one, the original signature is still maintained.

#24 @soulseekah
9 years ago

It used to return null which is falsey, now it returns an array which truthy. I'd err on the safe side as well.

#25 @desrosj
9 years ago

  • Milestone 4.9.6 → 5.0

I am going to move this to 5.0 because of the potential for issues with the change in returned values. If a committer is confident in this, it can be moved back in.

#26 @pento
8 years ago

  • Milestone 5.0 → 5.1

#27 @pento
8 years ago

  • Keywords needs-refresh added; dev-feedback removed
  • Milestone 5.1 → Future Release

It seems like it would be more useful for the array elements to be true or a WP_Error, with the error extracted from $client->error.

Also, $ping_status doesn't contain an error if discover_pingback_server_uri() is unable to discover the URI.

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


5 years ago

This ticket was mentioned in ​PR #2259 on ​WordPress/wordpress-develop by ​ironprogrammer.


5 years ago
#29

  • Keywords needs-refresh removed

Refresh on Trac 38197. Updates pingback to return an array of statuses, indexed by the links pinged.

Trac ticket: https://core.trac.wordpress.org/ticket/38197

#30 follow-up: @ironprogrammer
5 years ago

  • Keywords needs-unit-tests added

​PR 2259 refreshes the patch for suggested 6.0 release. This ticket was covered by @SergeyBiryukov during a new contributor meeting in Slack.

This PR will include unit tests for pingback, but their completion is blocked by #30580. The issue is that HTML entities in the local test pingback URLs are stripped by wp_extract_urls. I'll shift to the other ticket before being able to wrap this up.

Last edited 5 years ago by SergeyBiryukov (previous) (diff)

#31 @SergeyBiryukov
5 years ago

  • Milestone Future Release → 6.0

#32 @peterwilsoncc
5 years ago

  • Owner nathanatmoz removed

#33 in reply to: ↑ 30 @peterwilsoncc
5 years ago

Replying to ironprogrammer:

This PR will include unit tests for pingback, but their completion is blocked by #30580. The issue is that HTML entities in the local test pingback URLs are stripped by wp_extract_urls. I'll shift to the other ticket before being able to wrap this up.

The wp_extract_urls() changes were committed a few days ago so you should be unblocked now.

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


5 years ago

#35 @chaion07
5 years ago

  • Milestone 6.0 → Future Release

Thanks @dshanske for reporting this. We recently reviewed this ticket during a ​recent bug-scrub session. Noting that Beta 01 coming into effect by the end of today, the ticket is still awaiting unit tests and some additional work. Based on the feedback from the team we are updating the milestone of the ticket.

Props to @peterwilsoncc

Cheers!

This ticket was mentioned in ​PR #3379 on ​WordPress/wordpress-develop by ​CrochetFeve0251.


4 years ago
#36

  • Keywords has-unit-tests added; needs-unit-tests removed

Added unit tests for pingback function

Trac ticket: 38197

This ticket was mentioned in ​PR #6436 on ​WordPress/wordpress-develop by ​@pbearne.


3 years ago
#37

#38 @pbearne
3 years ago

  • Owner set to pbearne

refeshed

This ticket was mentioned in ​Slack in #core-performance by adamsilverstein. ​View the logs.


22 months ago

#40 @adamsilverstein
22 months ago

  • Keywords needs-refresh added

This ticket was mentioned in ​PR #8214 on ​WordPress/wordpress-develop by ​@audrasjb.


22 months ago
#41

  • Keywords needs-refresh removed

​@audrasjb commented on ​PR #3379:


22 months ago
#42

Closing in favor of #8214.

#43 @audrasjb
22 months ago

Previous patch refreshed.

#44 @pbearne
22 months ago

refreshed

#45 @pbearne
22 months ago

  • Milestone Future Release → 6.8

​@flixos90 commented on ​PR #8214:


21 months ago
#47

@audrasjb As far as I can tell, this is the same code as #6436, just with version numbers refreshed?

If so, ideally we should then close the older PR and reference it here, to ensure props aren't missed. cc @pbearne

​@flixos90 commented on ​PR #8214:


21 months ago
#48

FWIW given this PR still fails WPCS (see ​https://github.com/WordPress/wordpress-develop/actions/runs/13274870214/job/37062377047?pr=8214), it may be faster to just update the version numbers in #6436.

#49 @flixos90
21 months ago

  • Keywords commit added
  • Owner changed from pbearne to flixos90
  • Status assigned → reviewing

​@flixos90 commented on ​PR #8214:


21 months ago
#50

Closing in favor of #6436, which is good to commit.

#51 @flixos90
21 months ago

  • Resolution → fixed
  • Status reviewing → closed

In 59818:

Pings/Trackbacks: Add return value to pingback().

This facilitates debugging and better response / error handling, among other things.

Props audrasjb, coquardcyr, dshanske, ironprogrammer, NathanAtmoz, pbearne, shulard, soulseekah.
Fixes #38197.

Note: See TracTickets for help on using tickets.