[buddypress-trac] [BuddyPress Trac] #8592: bp_core_get_directory_page_ids ignores current multisite context

buddypress-trac noreply at wordpress.org
Thu Oct 28 12:00:59 UTC 2021


#8592: bp_core_get_directory_page_ids ignores current multisite context
--------------------------+-----------------------------
 Reporter:  thomaslhotta  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:  9.1.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 The ''bp_core_get_directory_page_ids'' function in ''src/bp-core/bp-core-
 functions.php'' is not aware on the current blog if running on a multisite
 setup. This can cause an issue with the following code in the foreach
 loop:

 {{{#!php
 // Trashed pages should never appear in results.
 if ( 'trash' == get_post_status( $page_id ) ) {
    unset( $page_ids[ $component_name ] );
 }
 }}}

 It checks if a post with $page_id as ID is trashed, but does this in the
 context of the current blog. So if we are currently not on the main blog
 and there is a post of any type that has a trashed status, this will
 remove the page form the array. This happened to me with a
 ''customize_changeset'' post type that by coincidence had the same id.

 I think that this is statement would have to be wrapped in something like
 this to work correctly:

 {{{#!php
 // Trashed pages should never appear in results.
 switch_to_blog( bp_get_root_blog_id() );
 if ( 'trash' == get_post_status( $page_id ) ) {
         unset( $page_ids[ $component_name ] );
 }
 restore_current_blog();
 }}}

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8592>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list