Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/02/2018 06:07:46 PM (6 years ago)
Author:
johnjamesjacoby
Message:

Meta: Prefer internal table references over $wpdb ones.

This change updates a few direct database queries to reference the database table names internally set by BP_Component rather than what's been passed into the $wpdb global.

We want to use these everywhere, as they are already in use everywhere else direct queries are made.

Blogs, Groups, and Messages meta deletion functions are affected.

See #7834.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-functions.php

    r12164 r12180  
    450450 */
    451451function bp_messages_delete_meta( $message_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
     452    global $wpdb;
     453
    452454    // Legacy - if no meta_key is passed, delete all for the item.
    453455    if ( empty( $meta_key ) ) {
    454         global $wpdb;
    455 
    456         $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->messagemeta} WHERE message_id = %d", $message_id ) );
     456        $table_name = buddypress()->messages->table_name_meta;
     457        $sql        = "SELECT meta_key FROM {$table_name} WHERE message_id = %d";
     458        $query      = $wpdb->prepare( $sql, $message_id );
     459        $keys       = $wpdb->get_col( $query );
    457460
    458461        // With no meta_key, ignore $delete_all.
Note: See TracChangeset for help on using the changeset viewer.