Opened 2 years ago
Last modified 15 months ago
#60038 reviewing enhancement
Pass original array of arguments to hooks that fire within `wp_insert_post()`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | good-first-bug has-patch changes-requested |
| Focuses: | Cc: |
Description
The $postarr value passed to the wp_insert_post() function contains context that can be useful to callbacks attached to the actions that fire within this function, but this value isn't passed to any of them. Strangely enough it is passed to most of the filters there.
As an example, a plugin of mine needs to perform logic within a callback on the wp_insert_post action based on a mixture of the tax_input argument and a custom argument. The wp_insert_post_data filter needs to be used to access these values.
The $postarr value gets copied to $unsanitized_postarr. This is the value that should be passed to the actions because it contains the original input array, rather than $postarr which includes defaults and sanitised values. Or both should be passed, as per the filters in the function.
This affects the following actions:
pre_post_updateedit_attachmentattachment_updatedadd_attachmentedit_post_{$post->post_type}edit_postpost_updatedsave_post_{$post->post_type}save_postwp_insert_post
And the following filters:
add_trashed_suffix_to_trashed_posts
Attachments (4)
Change History (16)
This ticket was mentioned in PR #5747 on WordPress/wordpress-develop by mrhatia.
2 years ago
#1
- Keywords has-patch added; needs-patch removed
There are some missing arguments in the core i added it and resolve following ticket
Trac ticket: https://core.trac.wordpress.org/ticket/60038
#2
@
2 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from Awaiting Review to Future Release
Thanks for the patch @rizwan_47! But, it doesn't do what I mentioned in the description. The $unsanitized_postarr array needs to be passed, either on its own or along with $postarr. Would you like to take another look?
#4
@
22 months ago
- Keywords has-patch added; needs-patch removed
I'm re-uploading 60038.2.2diff as it was corrupted. Specifically, it was in UTF-16LE, so I have converted it to UTF-8. I have not made any changes to the source code.
The content itself includes $unsanitized_postarr as an argument, which I believe meets the requirements. I'm also developing a plugin, and I find this to be more convenient.
I've changed the status to has-patch.
#5
@
19 months ago
- Milestone changed from Future Release to 6.6
- Owner set to johnbillion
- Status changed from new to reviewing
#6
@
19 months ago
@johnbillion, we have 1 week before Beta 1. Can you review the patch, please? It looks simple enought, but I am wondering if actions inside wp_publish_post() function should have the same properties for consistency.
This ticket was mentioned in Slack in #core by oglekler. View the logs.
19 months ago
#8
@
19 months ago
@johnbillion we have just a few days before Beta 1, so, place move this forward or to the next milestone. Thank you!
#9
@
19 months ago
- Keywords dev-feedback added
- Milestone changed from 6.6 to 6.7
We have 2 days before Beta 1, so I am moving it into the next milestone.
And I hope to get an opinion about if actions inside wp_publish_post() function should have the same properties for consistency.
#10
@
18 months ago
- Keywords changes-requested added; dev-feedback removed
This patch needs more work because the affected filters and actions also fire in other places in core, not just within the wp_insert_post() function.
This ticket was mentioned in Slack in #core-test by ankit-k-gupta. View the logs.
15 months ago
#13
@
15 months ago
- Milestone changed from 6.7 to Future Release
With 6.7 Beta 1 releasing in a few hours, this is being moved to Future Release given a lack of recent momentum towards a resolution.
@johnbillion If you or any other committer feels the remaining work can be resolved in time for Beta 1 or any other specific milestone and wishes to assume ownership during that cycle, feel free to update the milestone accordingly.
Added $postarr arg to the missing hooks and filter