From a630dd3e5748fa8b01572d362ba5b23fb8ca074f Mon Sep 17 00:00:00 2001 From: Jitendra Banjara Date: Tue, 14 May 2024 10:50:00 +0530 Subject: [PATCH 1/3] PROD-7421 - Fixed - PHP Warning: Undefined property: BP_XProfile_Component::$table_name_data --- src/bp-xprofile/classes/class-bp-xprofile-profiledata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php b/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php index 6faf2e30a5..c7a88ceb4a 100644 --- a/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php +++ b/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php @@ -517,7 +517,7 @@ public static function get_value_byid( $field_id, $user_ids = null ) { // Prime caches. if ( ! empty( $uncached_ids ) ) { $uncached_ids_sql = implode( ',', $uncached_ids ); - $table = $bp->profile->table_name_data; + $table = bp_core_get_table_prefix() . 'bp_xprofile_data'; $queried_data = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, field_id, value, last_updated FROM {$table} WHERE field_id = %d AND user_id IN ({$uncached_ids_sql})", $field_id ) ); // Rekey. From e04d7987ce7e60260452be03c5781cc8c6396d0b Mon Sep 17 00:00:00 2001 From: Jitendra Banjara Date: Tue, 14 May 2024 10:51:59 +0530 Subject: [PATCH 2/3] PROD-7421 - Update table name also dynamically --- src/bp-xprofile/classes/class-bp-xprofile-profiledata.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php b/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php index c7a88ceb4a..50cad8ce26 100644 --- a/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php +++ b/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php @@ -244,15 +244,15 @@ public function save() { do_action_ref_array( 'xprofile_data_before_save', array( $this ) ); if ( $this->is_valid_field() ) { + $table = bp_core_get_table_prefix() . 'bp_xprofile_data'; if ( $this->exists() && strlen( trim( $this->value ) ) ) { - $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_data} SET value = %s, last_updated = %s WHERE user_id = %d AND field_id = %d", $this->value, $this->last_updated, $this->user_id, $this->field_id ) ); + $result = $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET value = %s, last_updated = %s WHERE user_id = %d AND field_id = %d", $this->value, $this->last_updated, $this->user_id, $this->field_id ) ); } elseif ( $this->exists() && empty( $this->value ) ) { // Data removed, delete the entry. $result = $this->delete(); } else { - $table = bp_core_get_table_prefix() . 'bp_xprofile_data'; $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$table} (user_id, field_id, value, last_updated) VALUES (%d, %d, %s, %s)", $this->user_id, $this->field_id, $this->value, $this->last_updated ) ); $this->id = $wpdb->insert_id; } From 5afd5649e890ea841986a46b3718443e2dc08efc Mon Sep 17 00:00:00 2001 From: Jitendra Banjara Date: Tue, 14 May 2024 11:20:16 +0530 Subject: [PATCH 3/3] PROD-7421 - Add condition to check if bp avatar object is not set then set again with class --- src/bp-core/bp-core-avatars.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bp-core/bp-core-avatars.php b/src/bp-core/bp-core-avatars.php index 84d415fe21..4a02bdd1a2 100644 --- a/src/bp-core/bp-core-avatars.php +++ b/src/bp-core/bp-core-avatars.php @@ -1715,6 +1715,10 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) { if ( isset( $bp->avatar->$type ) ) { $retval = $bp->avatar->$type; } else { + if ( ! isset( $bp->avatar ) ) { + $bp->avatar = new stdClass(); + } + // If this value has been set in a constant, just use that. if ( defined( $constant ) ) { $retval = constant( $constant );