From 4a34f3f4301a0509ba597d4c45c67e1359d279ed Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 13 Feb 2007 07:54:57 +0000 Subject: [PATCH] r1403: - Fixed a bug in UserAPI::post_update() that would clear bug.username, bug.lastpostbyname, and bug.hiddenlastpostname if the displayname wasn't set - Reduce needless querying by not calling build_assignedto() in UserAPI::post_update() unless the displayname or email changes --- docs/changes.txt | 1 + includes/api_user.php | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6c87205..c1615f5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -17,6 +17,7 @@ - Can now mass update of bug fields from the search screen - Search system no longer stores the actual query of the search, but rather the paramters - Added a lost password reset system +- Fixed a bug in the User API that would clear the cached usernames in bug records on a save if the display name wasn't set 1.1.5 =============================== diff --git a/includes/api_user.php b/includes/api_user.php index 69061d1..6663cb4 100644 --- a/includes/api_user.php +++ b/includes/api_user.php @@ -218,14 +218,20 @@ class UserAPI extends API */ function post_update() { - $username = $this->registry->escape($this->values['displayname']); - $id = $this->values['userid']; - - $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET username = '$username' WHERE userid = $id"); - $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET lastpostbyname = '$username' WHERE lastpostby = $id"); - $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET hiddenlastpostbyname = '$username' WHERE hiddenlastpostby = $id"); + if (isset($this->values['displayname'])) + { + $username = $this->registry->escape($this->values['displayname']); + $id = $this->values['userid']; + + $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET username = '$username' WHERE userid = $id"); + $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET lastpostbyname = '$username' WHERE lastpostby = $id"); + $this->registry->db->query("UPDATE " . TABLE_PREFIX . "bug SET hiddenlastpostbyname = '$username' WHERE hiddenlastpostby = $id"); + } - build_assignedto(); + if (isset($this->values['displayname']) OR isset($this->values['email'])) + { + build_assignedto(); + } } // ################################################################### -- 2.22.5