Changeset 13159
- Timestamp:
- 12/04/2021 02:53:34 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r13147 r13159 503 503 * 504 504 * @since 1.5.0 505 * @since 10.0.0 Eventually switch the current site to BP root's one on multisite configs. 505 506 * 506 507 * @param string $status 'active' to return only pages associated with active components, 'all' to return all saved … … 512 513 function bp_core_get_directory_page_ids( $status = 'active' ) { 513 514 $page_ids = bp_get_option( 'bp-pages', array() ); 515 $switched = false; 516 517 /* 518 * Make sure to switch the current site to BP root's one, if needed. 519 * 520 * @see https://buddypress.trac.wordpress.org/ticket/8592 521 */ 522 if ( is_multisite() ) { 523 $bp_site_id = bp_get_root_blog_id(); 524 525 if ( $bp_site_id !== get_current_blog_id() ) { 526 switch_to_blog( $bp_site_id ); 527 $switched = true; 528 } 529 } 514 530 515 531 // Loop through pages. … … 535 551 unset( $page_ids[ $component_name ] ); 536 552 } 553 } 554 555 if ( true === $switched ) { 556 restore_current_blog(); 537 557 } 538 558 -
trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
r13133 r13159 286 286 287 287 /** 288 * @ticket BP8592 289 */ 290 public function test_bp_core_get_directory_pages_ids_ms_non_root_blog_trashed_same_page_id() { 291 if ( ! is_multisite() ) { 292 $this->markTestSkipped(); 293 } 294 295 // create a blog 296 $u = self::factory()->user->create(); 297 $b1 = self::factory()->blog->create( 298 array( 299 'user_id' => $u, 300 ) 301 ); 302 303 // Switch to blog and create a post with the same BP Members page ID. 304 switch_to_blog( $b1 ); 305 306 $dir_page_ids = bp_core_get_directory_page_ids(); 307 308 $p = self::factory()->post->create( 309 array( 310 'import_id' => $dir_page_ids['members'], 311 ) 312 ); 313 314 // Trash the post that matches the BP Members page ID on this sub-site 315 wp_trash_post( $dir_page_ids['members'] ); 316 317 // refetch BP directory page IDs 318 $page_ids = bp_core_get_directory_page_ids(); 319 320 // restore blog 321 restore_current_blog(); 322 323 // Now verify that our BP Members page was not wiped out 324 $this->assertTrue( $dir_page_ids['members'] === $page_ids['members'] ); 325 } 326 327 /** 288 328 * @ticket BP7193 289 329 */
Note: See TracChangeset
for help on using the changeset viewer.