Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#41842 closed enhancement (duplicate)

pingback() doesn't return anything

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

Description

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 7 years ago.
41842.2.diff (793 bytes) - added by mrmadhat 7 years ago.

Download all attachments as: .zip

Change History (8)

@mrmadhat
7 years ago

#1 @mrmadhat
7 years ago

Will return false on failure and true on success

#2 @mrmadhat
7 years ago

  • Keywords needs-patch needs-unit-tests added

#3 follow-up: @Soean
7 years 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.

@mrmadhat
7 years ago

#4 in reply to: ↑ 3 @mrmadhat
7 years ago

Thanks @Soean I've added it now.

#5 @dshanske
7 years 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
7 years 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.