The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Admin Dashboard Users Online Table showing unexpected error
#1
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
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)