Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.16.14

Bug #2214 LiveUser_Admin_Perm_Container_DB_Simple::removeUser() violates constraints
Submitted: 2004-08-25 13:31 UTC
From: mflaherty at clearmessage dot com Assigned: dufuz
Status: Closed Package: LiveUser
PHP Version: 4.3.3 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2004-08-25 13:31 UTC] mflaherty at clearmessage dot com
Description: ------------ LiveUser_Admin_Perm_Container_DB_Simple::removeUser() attempts to delete the parent liveuser_perm_users record before deleting its dependents. Naturally where constraints exists this will fail. Apply this patch to LiveUser/Admin/Perm/Container/DB_Simple.php Reproduce code: --------------- *** DB_Simple.php.orig Wed Aug 25 14:25:15 2004 --- DB_Simple.php Wed Aug 25 14:26:10 2004 *************** *** 1086,1104 **** return false; } - // Delete user from perm table (Perm/DB) - $query = ' - DELETE FROM - ' . $this->prefix . 'perm_users - WHERE - perm_user_id = ' . $permId; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - } - // Delete group assignments $query = 'DELETE FROM ' . $this->prefix . 'groupusers --- 1086,1091 ---- *************** *** 1130,1135 **** --- 1117,1135 ---- return $result; }; + // Delete user from perm table (Perm/DB) + $query = ' + DELETE FROM + ' . $this->prefix . 'perm_users + WHERE + perm_user_id = ' . $permId; + + $result = $this->dbc->query($query); + + if (DB::isError($result)) { + return $result; + } + return true; }

Comments

 [2004-08-27 14:07 UTC] dufuz
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. Just fixed this in the way that now the user is deleted the last. Is that what you talked about ? (Didn't test applying the patch, the other thing seemed most logical :))
 [2004-08-27 14:57 UTC] mflaherty at clearmessage dot com
Yeah, I know that out of the box this wouldn't be a problem because there are no foreign key constraints in the schema (which creates MyISAM tables anyhow), but I don't like to have databases that ignore referential integrity so I've preferred to create the foreign keys. As such it is helpful for the deletes to be in the correct order. Thank you.