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-notifications/classes/class-bp-notifications-notification.php

    r11888 r12753  
    557557     *              false.
    558558     */
    559     public static function check_access( $user_id, $notification_id ) {
     559    public static function check_access( $user_id = 0, $notification_id = 0 ) {
    560560        global $wpdb;
    561561
    562562        $bp = buddypress();
    563563
    564         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
     564        $query   = "SELECT COUNT(id) FROM {$bp->notifications->table_name} WHERE id = %d AND user_id = %d";
     565        $prepare = $wpdb->prepare( $query, $notification_id, $user_id );
     566        $result  = $wpdb->get_var( $prepare );
     567
     568        return $result;
    565569    }
    566570
Note: See TracChangeset for help on using the changeset viewer.