[wp-trac] [WordPress Trac] #55176: if $stickies in function stick_post is not array, it should be empty array

WordPress Trac noreply at wordpress.org
Wed Feb 16 06:51:13 UTC 2022


#55176: if  $stickies in function stick_post is not array, it should be empty array
--------------------------+-----------------------------
 Reporter:  denishua      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 {{{#!php
 <?php
 if ( ! is_array( $stickies ) ) {
                 $stickies = array( $post_id );
         }
 }}}



 should change to

 {{{#!php
 <?php
 if ( ! is_array( $stickies ) ) {
                 $stickies = array();
         }
 }}}

 Because of some reason, if we delete the sticky_posts option in
 wp_options, then we can never sticky a post, the following code always
 false:

 {{{#!php
 <?php
 if ( ! in_array( $post_id, $stickies, true ) ) {
                 $stickies[] = $post_id;
                 $updated    = update_option( 'sticky_posts', array_values(
 $stickies ) );
         }
 }}}

 so it will never execute update_option. so we can't stick post.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55176>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list