WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 21 months ago

Last modified 21 months ago

#34141 closed enhancement (fixed)

Allow Plugins Access to Pingback Source HTML

Reported by: dshanske Owned by: SergeyBiryukov
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Pings/Trackbacks Keywords: has-patch commit 4.5-early
Focuses: Cc:

Description

This came up as I was looking at trying to close #3491.

This is a 9 year old ticket that proposes that hooks be added to allow plugins access to trackback and pingback data.

@markjaquith had pointed out that the best solution is to use the preprocess comment hook, but this doesn't allow the data to be saved into the comment.

The simplest solution is to modify wp_insert_comment to save anything not in an existing field into comment meta and then modify pingbacks and trackbacks to save that data into the meta.

Attachments (5)

34141.diff (1.2 KB) - added by dshanske 2 years ago.
34141.2.diff (1.2 KB) - added by dshanske 2 years ago.
Alternate Implementation
34141.2.2.diff (1.2 KB) - added by dshanske 2 years ago.
Correction - Should be Array_Diff_key
34141.3.diff (3.4 KB) - added by SergeyBiryukov 2 years ago.
34141.4.diff (3.5 KB) - added by SergeyBiryukov 21 months ago.

Download all attachments as: .zip

Change History (33)

#1 @dshanske
2 years ago

  • Keywords 2nd-opinion needs-patch added
  • Summary changed from Allow Plugins Access to Pingback and Trackback Data to Allow Plugins Access to Pingback Data

So, the scope of this proposal is as follows.

  1. Pingback pass data on in $commentdata.
  2. Extra fields in $commentdata get saved by wp_insert_comment into $commentmeta or support this by plugin by passing the full $commentdata to the action hook comment_post.

@dshanske
2 years ago

#2 @dshanske
2 years ago

The diff I added uses the easier option of passing the entire $commentdata to the comment_post hook. This would allow any plugin to get access to the data.

#3 @dshanske
2 years ago

  • Keywords has-patch added; needs-patch removed

@dshanske
2 years ago

Alternate Implementation

@dshanske
2 years ago

Correction - Should be Array_Diff_key

#4 @dshanske
2 years ago

Added the second option for implementation that takes anything in $commentdata that isn't a standard field and saves it in meta.

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


2 years ago

#6 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 4.4

#7 @dshanske
2 years ago

There was concern expressed in Slack that allowing the stored HTML to be stored could be a security issue. However, looking at the pingback code, it strips all tags. Assuming it must predate wp_kses_post which strips only certain tags, but that was before my time.

Think this needs to be addressed as well, as currently, it occurs to me the concern is somewhat moot as all tags have already been stripped except links before it is saved...but on the other hand, that would strip any other type of markup if a plugin wanted to use it...

The best way to address that part of it may be to close this ticket by coming up with the code to pass the data, and address the presentation issue on the opened #32653.

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


2 years ago

#9 @dshanske
2 years ago

  • Summary changed from Allow Plugins Access to Pingback Data to Allow Plugins Access to Pingback Source HTML

#10 @dshanske
2 years ago

Tried to go a step further by a proposal on Ticket #32653.

#11 @DrewAPicture
2 years ago

@SergeyBiryukov: Best suggestion on moving forward with this?

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


2 years ago

#13 @wonderboymusic
2 years ago

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

#14 @wonderboymusic
2 years ago

  • Milestone changed from 4.4 to Future Release

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


2 years ago

#16 @wonderboymusic
2 years ago

I think meta adds should go against a whitelist

#17 @dshanske
2 years ago

The question is what is on the whitelist.

#18 follow-up: @SergeyBiryukov
2 years ago

  • Keywords commit 4.5-early added; 2nd-opinion removed

I think 34141.diff would be the preferred approach here.

In 34141.3.diff:

  • Rename $linea to $remote_source for clarity.
  • Add 'remote_source' to comment data, so it's available to the 'preprocess_comment' filter.
  • Pass comment data to the 'comment_post' filter.

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


2 years ago

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


2 years ago

#21 @SergeyBiryukov
2 years ago

  • Milestone changed from Future Release to 4.5

#22 in reply to: ↑ 18 @westi
22 months ago

Replying to SergeyBiryukov:

I think 34141.diff would be the preferred approach here.

In 34141.3.diff:

  • Rename $linea to $remote_source for clarity.
  • Add 'remote_source' to comment data, so it's available to the 'preprocess_comment' filter.
  • Pass comment data to the 'comment_post' filter.

This looks like a sane solution to me.

I don't think we should auto-persist the remote-source but making it available for plugins to use seems like a reasonable idea.

#23 follow-up: @dshanske
22 months ago

The only change I was thinking of proposing was that it should be the raw, not the completely altered remote source passed in. The point of resolving this update to a nine year old issue is that a plugin could offer a pingback that is less useless in its display than the default.

#24 in reply to: ↑ 23 @SergeyBiryukov
21 months ago

Replying to dshanske:

The only change I was thinking of proposing was that it should be the raw, not the completely altered remote source passed in. The point of resolving this update to a nine year old issue is that a plugin could offer a pingback that is less useless in its display than the default.

34141.4.diff stores the original response in $remote_source_original and passes it to preprocess_comment and comment_post filters as well.

#25 @dshanske
21 months ago

I think that addresses everything.

#26 @SergeyBiryukov
21 months ago

In 36660:

Comments: Pass comment data to the comment_post filter.

Props dshanske.
See #34141.

#27 @SergeyBiryukov
21 months ago

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

In 36661:

Comments: In wp_xmlrpc_server::pingback_ping():

  • Rename $linea to $remote_source for clarity.
  • Add remote_source to comment data, so it's available to preprocess_comment and comment_post filters.
  • Pass the original (unfiltered) response source to the filters too (as remote_source_original in comment data).

Props dshanske for the original patch.
Fixes #34141.

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


21 months ago

Note: See TracTickets for help on using tickets.