diff --git a/api/cora/cora.php b/api/cora/cora.php index 3cb9270..274fd32 100644 --- a/api/cora/cora.php +++ b/api/cora/cora.php @@ -1030,15 +1030,6 @@ final class cora { $response_query_count = $this->response_query_counts[$index]; $response_query_time = $this->response_query_times[$index]; - // The data could be an integer, an XML string, an array, etc, but let's - // just always json_encode it to keep things simple and standard. - if($this->content_type_is_loggable() === true) { - $response_data = substr(json_encode($this->response_data[$index]), 0, 16384); - } - else { - $response_data = null; - } - $from_cache = $this->from_cache[$index]; $api_log_resource->create( @@ -1050,7 +1041,6 @@ final class cora { 'request_arguments' => preg_replace('/"(password)":".*"/', '"$1":"[removed]"', $request_arguments), 'response_error_code' => $response_error_code, 'response_data' => null, // Can't store this; uses too much disk. - // 'response_data' => preg_replace('/"(password)":".*"/', '"$1":"[removed]"', $response_data), 'response_time' => $response_time, 'response_query_count' => $response_query_count, 'response_query_time' => $response_query_time, diff --git a/api/user.php b/api/user.php index cf4128d..84bd0d9 100644 --- a/api/user.php +++ b/api/user.php @@ -166,7 +166,14 @@ class user extends cora\crud { } /** - * Set a setting on a user. + * Set a setting on a user. This utilizes a lock because all settings are + * stored in a single JSON column. If multiple settings are updated rapidly, + * they will both read from the user at the same time, then run their + * updates sequentially and overwrite each other with old data. + * + * Don't release the lock either...wait for the database connection to close + * and the transaction to commit otherwise anything waiting will start and + * get old data. * * @param string $key * @param string $value @@ -174,6 +181,9 @@ class user extends cora\crud { * @return array The new settings list. */ public function update_setting($key, $value) { + $lock_name = 'user->update_setting(' . $this->session->get_user_id() . ')'; + $this->database->get_lock($lock_name, 1); + $user = $this->get($this->session->get_user_id()); if($user['settings'] === null) { $settings = [];