Ticket #6244: 6244.02.patch
| File 6244.02.patch, 3.1 KB (added by , 11 years ago) |
|---|
-
src/bp-core/admin/bp-core-components.php
299 299 $current_action = $_GET['action']; 300 300 } 301 301 302 $current_components = buddypress()->active_components; 302 $current_components = buddypress()->active_components; 303 $packaged_components = array_flip( bp_core_get_packaged_component_ids() ); 304 $custom_active_components = array_diff_key( $current_components, $packaged_components ); 303 305 304 306 switch ( $current_action ) { 305 307 case 'retired' : … … 307 309 foreach ( array_keys( $retired_components ) as $retired_component ) { 308 310 if ( ! isset( $submitted[ $retired_component ] ) ) { 309 311 unset( $current_components[ $retired_component ] ); 312 313 // Make sure custom components does not contain a retired component 314 if ( isset( $custom_active_components[ $retired_component ] ) ) { 315 unset( $custom_active_components[ $retired_component ] ); 316 } 310 317 } 311 318 } 312 319 // fall through … … 322 329 break; 323 330 } 324 331 325 return $components; 332 // Active components is the list of packaged and custom components 333 return array_merge( $components, $custom_active_components ); 326 334 } 327 335 328 336 /** -
tests/phpunit/testcases/admin/functions.php
38 38 $this->assertEquals( bp_admin_list_table_current_bulk_action(), 'foo' ); 39 39 } 40 40 41 /** 42 * @group bp_core_admin_get_active_components_from_submitted_settings 43 */ 41 44 public function test_bp_core_admin_get_active_components_from_submitted_settings() { 42 45 $get_action = isset( $_GET['action'] ) ? $_GET['action'] : null; 43 46 $ac = buddypress()->active_components; … … 122 125 } 123 126 124 127 /** 128 * @group BP6244 129 * @group bp_core_admin_get_active_components_from_submitted_settings 130 */ 131 public function test_bp_core_admin_get_active_components_from_submitted_settings_should_keep_custom_component_directory_page() { 132 $bp = buddypress(); 133 $reset_active_components = $bp->active_components; 134 135 // Create and activate the foo component 136 $bp->foo = new BP_Component; 137 $bp->foo->id = 'foo'; 138 $bp->foo->slug = 'foo'; 139 $bp->foo->name = 'Foo'; 140 $bp->active_components[ $bp->foo->id ] = 1; 141 $new_page_ids = array( $bp->foo->id => $this->factory->post->create( array( 142 'post_type' => 'page', 143 'post_title' => $bp->foo->name, 144 'post_name' => $bp->foo->slug, 145 ) ) ); 146 147 $page_ids = array_merge( $new_page_ids, (array) bp_core_get_directory_page_ids() ); 148 bp_core_update_directory_page_ids( $page_ids ); 149 150 $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $reset_active_components ); 151 bp_core_add_page_mappings( $bp->active_components ); 152 153 $this->assertContains( $bp->foo->id, array_keys( bp_core_get_directory_page_ids() ) ); 154 155 // Reset buddypress() vars 156 $bp->active_components = $reset_active_components; 157 } 158 159 /** 125 160 * @group bp_core_activation_notice 126 161 */ 127 162 public function test_bp_core_activation_notice_register_activate_pages_notcreated_signup_allowed() {