Make WordPress Core

Opened 16 years ago

Closed 9 years ago

#7422 closed enhancement (wontfix)

pass $post_id to filters in sanitize_post_field() on post updates - same for users, etc.

Reported by: whoismanu's profile whoismanu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch needs-testing gsoc close
Focuses: Cc:

Description

the function sanitize_post_field in wp-includes/post.php calls most of the "database writes" post filters (e.g. content_save_pre). if a post is updated or created, the function is called in a database context ('db' == $context) and the $post_id argument is not passed to the "database writes" filters. while i understand this behavior on post creation ($post_id not yet available) it seems to me that on a post update the $post_id is readily available and could/should be passed to the filters as well.

an example where this would be useful is a case where i want to access a custom field value of a post that is currently being updated from the function hooked into content_save_pre. in its current form without the $post_id argument this doesn't seem to be possible.

Attachments (1)

7422.diff (2.5 KB) - added by wojtek.szkutnik 14 years ago.

Download all attachments as: .zip

Change History (8)

#1 @ryan
16 years ago

  • Milestone changed from 2.7 to 2.8

#2 @FFEMTcJ
15 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.8 to Future Release

#3 @Denis-de-Bernardy
15 years ago

  • Keywords filters sanitize_post_field posting removed
  • Summary changed from pass $post_id to filters in sanitize_post_field() on post updates to pass $post_id to filters in sanitize_post_field() on post updates - same for users, etc.

the same holds for users and other pieces of data.

what's usually done instead is you post-process the post (on the save_post hook)

#4 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Administration

#5 @wojtek.szkutnik
14 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch needs-testing gsoc added; needs-patch removed

It shouldn't hurt anyone and in some cases might prove to be useful

#6 @jeremyfelt
10 years ago

  • Component changed from Administration to Posts, Post Types
  • Keywords close added

It seems like this behavior was added with intent in [5796] via #4546, hence the separation of context.

That said, it also seems like this could also be accomplished (as mentioned above) on a save_post hook instead.

Suggesting wontfix

#7 @wonderboymusic
9 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This can be accomplished with other filters now

Note: See TracTickets for help on using tickets.