#58392 closed enhancement (fixed)
Add $post parameter to the wp_trash_post action.
Reported by: | mujuonly | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
The $post
variable is already available in the wp_trash_post()
function so it can just be passed.
Should be the same for the below functions as well to maintain the consistency
trashed_post
untrash_post
untrashed_post
Attachments (2)
Change History (22)
This ticket was mentioned in PR #4499 on WordPress/wordpress-develop by @mujuonly.
19 months ago
#1
- Keywords has-patch added
#2
@
19 months ago
- Keywords changes-requested added
Hi there! thanks for the ticket and PR.
Left one minor feedback.
#3
@
19 months ago
- Keywords dev-feedback added; has-patch changes-requested removed
Hi,
I checked the source code and I saw trashed_post, untrash_post, untrashed_post methods require post id not post and used multiple places. I think post id is the best.
#4
@
19 months ago
- Milestone changed from Awaiting Review to 6.3
Hi there, thanks for the ticket!
Taking a closer look here:
pre_trash_post
receives$post
.wp_trash_post
receives$post_id
.trashed_post
receives$post_id
.pre_untrash_post
receives$post
and$previous_status
.untrash_post
receives$post_id
and$previous_status
.untrashed_post
receives$post_id
and$previous_status
.
See [49125] / #23022 for reference.
It appears that passing $previous_status
to the former three hooks would bring more consistency, so 58392.2.diff does just that.
Would that be enough here, or do we still need to pass $post
to wp_trash_post
and untrash_post
? Could you share the use case for that?
This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.
19 months ago
#6
@
19 months ago
- Keywords needs-unit-tests added
This ticket was discussed during the bug scrub. As this is new code and to ensure that the parameters are always passed in future, we agreed that this should have a unit test to verify the expected parameters are received.
Additional props: @mukesh27 @oglekler
This ticket was mentioned in Slack in #core by oglekler. View the logs.
18 months ago
This ticket was mentioned in PR #4580 on WordPress/wordpress-develop by @hugod.
18 months ago
#9
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/58392
This PR adds unit tests to the previously proposed diff.
#10
@
18 months ago
Hi,
I added tests in https://github.com/WordPress/wordpress-develop/pull/4580.
Tell me if it lacks of anything.
This ticket was mentioned in Slack in #core by hugod. View the logs.
18 months ago
18 months ago
#13
Hi @audrasjb and @costdev 👋
Thanks for the feedback!
I've split the test and added some docblocks as you suggested.
#15
@
18 months ago
- Owner set to audrasjb
- Status changed from new to reviewing
Self assigning for final review.
This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.
18 months ago
#17
@
18 months ago
- Keywords needs-testing added; dev-feedback removed
I am adding needs-testing
to highlight that this patch is ready for review.
@audrasjb commented on PR #4580:
18 months ago
#20
committed in https://core.trac.wordpress.org/changeset/56043
Add $post parameter to wp_trash_post action
Trac ticket: https://core.trac.wordpress.org/ticket/58392