Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/15/2020 04:33:31 PM (4 years ago)
Author:
imath
Message:

Core: use only one global to store the Notifications DB table name

  • Deprecate $bp->core->table_name_notifications.
  • Add a magic getter to BP_Core, with a fallback if the Notifications component isn't active.
  • Audit the related queries and method params, and makes sure they work as intended, and update them to our latest coding standards.

Props johnjamesjacoby

Fixes #8360

File:
1 edited

Legend:

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

    r12627 r12753  
    3737
    3838    /**
     39     * Magic getter.
     40     *
     41     * This exists specifically for supporting deprecated object vars.
     42     *
     43     * @since 7.0.0
     44     *
     45     * @param string $key
     46     * @return mixed
     47     */
     48    public function __get( $key = '' ) {
     49
     50        // Backwards compatibility for the original Notifications table var
     51        if ( 'table_name_notifications' === $key ) {
     52            return bp_is_active( 'notifications' )
     53                ? buddypress()->notifications->table_name
     54                : buddypress()->table_prefix . 'bp_notifications';
     55        }
     56
     57        // Return object var if set, else null
     58        return isset( $this->{$key} )
     59            ? $this->{$key}
     60            : null;
     61    }
     62
     63    /**
    3964     * Populate the global data needed before BuddyPress can continue.
    4065     *
     
    249274         */
    250275        $bp->grav_default->blog  = apply_filters( 'bp_blog_gravatar_default',  $bp->grav_default->user );
    251 
    252         // Notifications table. Included here for legacy purposes. Use
    253         // bp-notifications instead.
    254         $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
    255276
    256277        // Backward compatibility for plugins modifying the legacy bp_nav and bp_options_nav global properties.
Note: See TracChangeset for help on using the changeset viewer.