Skip to content

Commit

Permalink
Merge pull request #4407 from buddyboss/PROD-7421
Browse files Browse the repository at this point in the history
PROD-7421 - PHP Notice:  Undefined property: stdClass::$table_name_data when activate platform with fresh installation
  • Loading branch information
KartikSuthar authored May 30, 2024
2 parents 8c07e23 + 8437f9d commit 5e6c84b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/bp-core/bp-core-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5e6c84b

Please sign in to comment.