Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2018 04:09:00 PM (7 years ago)
Author:
boonebgorges
Message:

Avoid passing non-variables to empty() throughout codebase.

This ensures full compatibility with versions of PHP earlier than 5.5.

In some cases, we avoid the use of empty() by moving to its equivalent,
! isset( $foo ) || ! $foo. In some cases, we convert the tested value
to a variable before passing to empty().

See #7998.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r12224 r12281  
    139139
    140140    // Use the string provided by the component.
    141     if ( ! empty( buddypress()->{$component}->directory_title ) ) {
     141    if ( isset( buddypress()->{$component}->directory_title ) && buddypress()->{$component}->directory_title ) {
    142142        $title = buddypress()->{$component}->directory_title;
    143143
     
    11501150 */
    11511151function bp_account_was_activated() {
    1152     $activation_complete = ! empty( buddypress()->activation_complete ) || ( bp_is_current_component( 'activate' ) && ! empty( $_GET['activated'] ) );
     1152    $bp = buddypress();
     1153
     1154    $activation_complete = ! empty( $bp->activation_complete ) || ( bp_is_current_component( 'activate' ) && ! empty( $_GET['activated'] ) );
    11531155
    11541156    return $activation_complete;
     
    20822084            }
    20832085
    2084             if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
     2086            $component_features = isset( buddypress()->{$component}->features ) ? buddypress()->{$component}->features : array();
     2087
     2088            if ( empty( $component_features ) || false === in_array( $feature, $component_features, true ) ) {
    20852089                $retval = false;
    20862090            }
Note: See TracChangeset for help on using the changeset viewer.