#18044 closed defect (bug) (invalid)
`delete_post` hook has off-by-1 error in `$postid` parameter
Reported by: | meitar | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2 |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
In WordPress 3.2, the delete_post
hook seems to be passed the incorrect post ID. Specifically, if a post's ID is 5, then the functioned called by the delete_post
hook is passed an integer value of 6
, contradicting $_GET['post']
(of a string value of 5
, in this example).
Attached to this ticket is a very crude plugin showing the problem. I have tested the same plugin against WordPress 3.1.4 and the issue is not visible there. To see the issue in action:
- Install the plugin & activate the plugin.
- Create a new post.
- Delete that post.
Is this a regression?
Attachments (1)
Change History (3)
#1
@
13 years ago
- Resolution set to invalid
- Status changed from new to closed
The ID being passed to the filter is a post revision, the $_GET value is the parent post ID. In my test these were 849 and 838 respectively, so being off by one is coincidence.
'delete_post' is actually invoked for each revision before the parent post, so if you remove the exit from your test code, you should see they match in the final iteration.
Crude plugin that shows off-by-1 error in
delete_post
hook.