Make WordPress Core

Opened 9 months ago

Closed 3 months ago

#41842 closed enhancement (duplicate)

pingback() doesn't return anything

Reported by: mrmadhat Owned by:
Milestone: Priority: low
Severity: minor Version: 2.1
Component: Pings/Trackbacks Keywords: needs-patch needs-unit-tests
Focuses: Cc:


The pingback() function doesn't return any value. This makes it hard to test and validate that it worked.

Attachments (2)

41842.diff (434 bytes) - added by mrmadhat 9 months ago.
41842.2.diff (793 bytes) - added by mrmadhat 9 months ago.

Download all attachments as: .zip

Change History (8)

9 months ago

#1 @mrmadhat
9 months ago

Will return false on failure and true on success

#2 @mrmadhat
9 months ago

  • Keywords needs-patch needs-unit-tests added

#3 follow-up: @Soean
9 months ago

Hello @mrmadhat, welcome to trac and thanks for your patch. With this change, you have to add a return type to the function DocBlock see Inline documentation standards.

9 months ago

#4 in reply to: ↑ 3 @mrmadhat
9 months ago

Thanks @Soean I've added it now.

#5 @dshanske
9 months ago

  • Priority changed from normal to low
  • Severity changed from normal to minor

This is a good simple fix, but this is problematic because it doesn't really validate whether it worked per se, it measures whether or not the post ID exists. It doesn't measure whether the pingbacks themselves succeed.

So the question is...what is success and failure in this case?

What I would suggest is splitting sending a single pingback into its own function, for example, 'ping' with the arguments $pagelinkedfrom, $pagelinkedto which will return success of failure for a single ping.

The problem is then...if a URL has multiple links in it, and it tries to ping all of them, what constitutes failure? Do they all have to be true? Sometimes, some of them don't have pingback support? Is that a success or a failure?

It may be better to return a WP_Error object that can attach additional data.

#6 @dshanske
3 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #38197

Note: See TracTickets for help on using tickets.