Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/10/2015 03:24:04 PM (10 years ago)
Author:
boonebgorges
Message:

bp_core_get_directory_page_ids() should skip bp_is_active() check in save context.

In [9177], a bp_is_active() check was added to bp_core_get_directory_page_ids()
such that the function would not return page mappings for inactive components.
This change caused problems for custom components, as the bp_is_active()
check didn't always pass for components that didn't manually set themselves in
the active_components array. [9553] and [9555] addressed this problem by only
filtering out packaged components. See #6244. But this fix was not truly
general, as it still resulted in the deletion of bp-pages entries related to
third-party deactivated components when saving the page mapping settings.

This changeset introduces a more general fix, by distinguishing between two
different use "contexts" of bp_core_get_directory_page_ids():

  • Read-only - When pulling up page IDs for display or for URI parsing, deactivated components should be ignored.
  • Save - When modifying the bp-pages array stored in the database, we should be working with raw page data, including deactivated components.

The new $status parameter for bp_core_get_directory_page_ids() addresses
this distinction (possible values 'all' and 'active'). We then pass 'all' as
required in BP - namely, when modifying the bp-pages setting. This change
supercedes the fixes from #6244.

Props dtc7240, boonebgorges.
Fixes #6280.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/src/bp-core/admin/bp-core-components.php

    r9553 r9609  
    300300    }
    301301
    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 );
     302    $current_components = buddypress()->active_components;
    305303
    306304    switch ( $current_action ) {
     
    310308                if ( ! isset( $submitted[ $retired_component ] ) ) {
    311309                    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                     }
    317310                }
    318311            }
     
    330323    }
    331324
    332     // Active components is the list of packaged and custom components
    333     return array_merge( $components, $custom_active_components );
     325    return $components;
    334326}
    335327
Note: See TracChangeset for help on using the changeset viewer.