Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROD-7421 - PHP Notice: Undefined property: stdClass::$table_name_data when activate platform with fresh installation #4407

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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