wordpress-webmention icon indicating copy to clipboard operation
wordpress-webmention copied to clipboard

Async Processing

Open dshanske opened this issue 9 years ago • 13 comments

http://indiewebcamp.com/webmention-spec

The webmention specification states that the webmention should be queued and processed asynchronously to avoid DoS attacks.

dshanske avatar Dec 20 '15 06:12 dshanske

There is a more ambitious proposal I put through for Core if this ever happens. But within the scope of this plugin, would like to see about using wp-cron to delay remote retrieval.

dshanske avatar Mar 07 '16 18:03 dshanske

@dshanske do you have an idea how we can start with that? Perhaps we save all mentions in a custom post cue and either process them directly or running a cron.

@petermolnar how do you handle this problem in your plugin?

pfefferle avatar Sep 30 '16 08:09 pfefferle

ah, @petermolnar is cueing a single cron with the URL as param... this is a nice and simple idea, but it makes it hard to provide a status API... hmmm...

pfefferle avatar Sep 30 '16 09:09 pfefferle

Oh no, this is only for the archive.org call... the Webmentions are cued in an extra webmention table... But I will avoid creating a new table... hmmm...

pfefferle avatar Sep 30 '16 09:09 pfefferle

My idea was a custom comment status.

dshanske avatar Sep 30 '16 09:09 dshanske

wp_insert_comment allows a comment to be stored in the database without going through the usual filters/actions. We can then trigger those filters after source verification.

dshanske avatar Sep 30 '16 09:09 dshanske

OK... have you tried adding comments with an unsupported status?

pfefferle avatar Sep 30 '16 10:09 pfefferle

No, I need to test out this idea to see if it would work.

dshanske avatar Sep 30 '16 10:09 dshanske

OK, but this is nevertheless a nice idea!

pfefferle avatar Sep 30 '16 10:09 pfefferle

Once we finish the API integration, I'm going to try this as a branch.

dshanske avatar Oct 17 '16 16:10 dshanske

https://github.com/A5hleyRich/wp-background-processing - This looks promising.

dshanske avatar Jan 01 '17 03:01 dshanske

I read a little bit in the docs, but in the end it also uses a wp_schedule_event, so I am not sure if we need the overhead of this classes...

pfefferle avatar Jan 06 '17 23:01 pfefferle

@pfefferle Revisiting this in light of #474, and thinking of conducting the tests of how an unsupported status might work. Technically, the comment table doesn't have a custom status, it has comment_approved, which acts as an unofficial status.

WP_Comment_Query has the argument - Comment statuses to limit results by. Accepts an array or space/comma-separated list of 'hold' (comment_status=0), 'approve' (comment_status=1), 'all', or a custom comment status. Default 'all'.

However, ready the actual code, the documentation is off. https://github.com/WordPress/wordpress-develop/blob/6.5/src/wp-includes/class-wp-comment-query.php#L559 . All is actually 0 or 1, and there is an 'any' status that would show hidden types.

So, it looks like a custom comment status wouldn't be picked up anywhere by default, but should be easy enough to test just to make sure.

If so, we could store incoming webmentions with a 'queued' status and a type of webmention, then schedule a query in the background process to run through them.

dshanske avatar May 25 '24 15:05 dshanske