[wp-trac] [WordPress Trac] #50567: Set $post filter in update_post_cache()

WordPress Trac noreply at wordpress.org
Thu Nov 4 02:18:33 UTC 2021


#50567: Set $post filter in update_post_cache()
----------------------------------------+-----------------------------
 Reporter:  Cybr                        |       Owner:  hellofromTonya
     Type:  defect (bug)                |      Status:  assigned
 Priority:  normal                      |   Milestone:  5.9
Component:  Posts, Post Types           |     Version:  5.5
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  performance
----------------------------------------+-----------------------------

Comment (by Cybr):

 > I still think the cached value will need to be `raw` sanitization as
 that's the most common use case (almost all calls to get post are simply
 `get_post( $post_id )`).

 This skipped my mind, so I forwarded the PR as-is-proposed in the patch
 attached to this ticket.

 Still, another check against `'raw' !== $post->filter` wouldn't hurt.
 Please note the discrepancy with `WP_Post::get_instance()`, which could be
 addressed as described below.

 This...:
 {{{#!php
 <?php
 // ..
 } elseif ( empty( $_post->filter ) ) {
         $_post = sanitize_post( $_post, 'raw' );
 }
 // ..
 }}}

 ...would then become:
 {{{#!php
 <?php
 // ..
 } elseif ( empty( $_post->filter ) || 'raw' !== $_post->filter ) {
         $_post = sanitize_post( $_post, 'raw' );
 }
 // ..
 }}}

 @peterwilsoncc, do you wish for me to forward that in the PR?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50567#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list