09-15-2016, 04:10 PM
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
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