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-blogs/bp-blogs-activity.php

    r12169 r12281  
    11591159    // Initialize a local object so we won't have to query this again in the
    11601160    // comment loop.
    1161     if ( empty( buddypress()->blogs->allow_comments ) ) {
     1161    if ( ! isset( buddypress()->blogs->allow_comments ) ) {
    11621162        buddypress()->blogs->allow_comments = array();
    11631163    }
    1164     if ( empty( buddypress()->blogs->thread_depth ) ) {
     1164    if ( ! isset( buddypress()->blogs->thread_depth ) ) {
    11651165        buddypress()->blogs->thread_depth   = array();
    11661166    }
    1167     if ( empty( buddypress()->blogs->comment_moderation ) ) {
     1167    if ( ! isset( buddypress()->blogs->comment_moderation ) ) {
    11681168        buddypress()->blogs->comment_moderation = array();
    11691169    }
     
    12431243            // If comments are closed for the WP blog post, we should disable
    12441244            // activity comments for this activity entry.
    1245             if ( empty( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) ) {
     1245            if ( ! isset( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) || ! buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) {
    12461246                $retval = false;
    12471247            }
    12481248
    12491249            // If comments need moderation, disable activity commenting.
    1250             if ( ! empty( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) ) {
     1250            if ( isset( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) && buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) {
    12511251                $retval = false;
    12521252            }
     
    13291329        // The blog post has closed off commenting, so we should disable all activity
    13301330        // comments under the parent 'new_blog_post' activity entry.
    1331         if ( empty( buddypress()->blogs->allow_comments[$comment->item_id] ) ) {
     1331        if ( ! buddypress()->blogs->allow_comments[ $comment->item_id ] ) {
    13321332            $retval = false;
    13331333        }
     
    13351335
    13361336    // If comments need moderation, disable activity commenting.
    1337     if ( ! empty( buddypress()->blogs->comment_moderation[$comment->item_id] ) ) {
     1337    if ( isset( buddypress()->blogs->comment_moderation[ $comment->item_id ] ) && buddypress()->blogs->comment_moderation[ $comment->item_id ] ) {
    13381338        $retval = false;
    13391339    }
Note: See TracChangeset for help on using the changeset viewer.