Using Moodle 1.8.2 (2007021520) debian package, with Postgres 8.2.5 and PHP 5.2.4.2
I get the following SQL error when I show the Online Users block in debug mode.
"ERROR: column "u.username" must appear in the GROUP BY clause or be used in an aggregate function
SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess, ul.timeaccess FROM mdl_user_lastaccess ul, mdl_user u WHERE ul.userid = u.id AND (ul.timeaccess > 1193671800 OR u.lastaccess > 1193671800) GROUP BY u.id ORDER BY ul.timeaccess DESC
- line 677 of lib/dmllib.php: call to debugging()
- line 918 of lib/dmllib.php: call to get_recordset_sql()
- line 83 of blocks/online_users/block_online_users.php: call to get_records_sql()
- line 202 of blocks/moodleblock.class.php: call to block_online_users->get_content()
- line 226 of blocks/moodleblock.class.php: call to block_base->is_empty()
- line 331 of lib/blocklib.php: call to block_base->_print_block()
- line 275 of index.php: call to blocks_print_group()"
I think this is a true SQL coding error.
See http://www.postgresql.org/docs/8.2/interactive/queries-table-expressions.html#QUERIES-GROUP
In file block_online_users.php I would expect something like :
At line 67 :
$SQL = "SELECT u.id, u.username, u.firstname, u.lastname, u.picture, MAX(u.lastaccess) AS mlastacess, MAX(ul.timeaccess) AS mtimeaccess
FROM {$CFG->prefix}user_lastaccess ul,
{$CFG->prefix}user u
$groupmembers
WHERE
ul.userid = u.id
$courseselect
$timeselect
$groupselect
GROUP BY u.id, u.username, u.firstname, u.lastname, u.picture
ORDER BY MAX(ul.timeaccess) DESC";
At line 119 :
$timeago = format_time(time() - max($user->mtimeaccess, $user->mlastaccess)); //bruno to calculate correctly on frontpage
I wonder how we can choose between ordering by MAX(ul.timeaccess) and ordering by MAX(u.lastaccess) ?
Somehow I hit enter before finishing with the issue editor.
Was using a daily build from last week. Only the admin login would show in the block. Install build from 8-21-2007 and not even admin gets listed now.
Env: PHP 5.1.6 / Apache 2.2.3