The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Admin Dashboard Users Online Table showing unexpected error - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Admin Dashboard Users Online Table showing unexpected error (/showthread.php?tid=269) |
Admin Dashboard Users Online Table showing unexpected error - Angel - 09-15-2016 Hi UserSpice developers, First I would like to thank you guys for developing such a nice software! As I'm implementing Userspice in my project, I found that after I delete a user from the admin_users.php, the "Loggedin Users" table in admin dashboard is showing errors like this: Notice: Undefined offset: 0 in D:\wwwroot\SET_Apps\users\classes\DB.php on line 155 Notice: Trying to get property of non-object in D:\wwwroot\SET_Apps\users\helpers\helpers.php on line 67 I later realized that this happens because when the user is deleted, it is deleted from these three tables according to us_helpers.php: function deleteUsers($users) { $db = DB::getInstance(); $i = 0; foreach($users as $id){ $query1 = $db->query("DELETE FROM users WHERE id = ?",array($id)); $query2 = $db->query("DELETE FROM user_permission_matches WHERE user_id = ?",array($id)); $query3 = $db->query("DELETE FROM profiles WHERE user_id = ?",array($id)); $i++; } return $i; } But perhaps the users_online table should also be updated in this for loop. so I added one line of code in this function, now it looks like this: function deleteUsers($users) { $db = DB::getInstance(); $i = 0; foreach($users as $id){ $query1 = $db->query("DELETE FROM users WHERE id = ?",array($id)); $query2 = $db->query("DELETE FROM user_permission_matches WHERE user_id = ?",array($id)); $query3 = $db->query("DELETE FROM profiles WHERE user_id = ?",array($id)); //########################################################## Changed by Angel Sun $query4 = $db->query("DELETE FROM users_online WHERE user_id = ?",array($id)); //########################################################## Changed by Angel Sun $i++; } return $i; } Now the admin dashboard error goes away. I'm using Userspice 4.1.3. If this bug is already fixed in the newest version, please ignore this report. Thanks Angel |