User tests: Successful: Unsuccessful:
Pull Request for Issue #46033
Edit this file administrator/modules/mod_logged/src/Helper/LoggedHelper.php
Add this code: ->order('s.time DESC')
on line 50 to sort the list of Module Logged In Users in descending order by datetime.
Create an Admin Module: Logged-in Users
Users to Display: 10 (for example)
Name: Name or Username
Position: select the desired position
Status: Published
Then SAVE the Module.
See the result in the position you choose.
The list in the module table is not sorted properly.
The list in the module table should be sorted by datetime in descending order.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Modules Administration |
New features have to be made for 6.1-dev.
I seem to be getting odd results after applying the Patch:
Vivaldi 7.5.3735.66 - Administrator
Google 140.0.7339.81 - Administrator
Notice how the order is NOT the same between the 3 browsers?!
@samuelagus any reason for this?
@alikon - which browser did you test with and did you test with more than 1?
Perhaps a stupid concept - time is NOT just 19:38 from a computer point of view right? (seconds are hidden, right i.e. 19:38:01 etc and all three have different time stamps (i.e. I switched browsers for each login so they have 2-10 seconds difference between them - so they should be all showing in the same order)? (or is Joomla truly cutting off time at 2 decimals? and therefore it's normal that each browser handles the order differently...
EITHER way, this is BEFORE the patch:
with the PR patch:
I thought the BEFORE and AFTER were supposed to be different (sorry if I misunderstood). Thanks.
@samuelagus any reason for this?
This is the sample screenshot of session table in PhpMyAdmin:
Is it possible that the default ordering of the table is by first column, in this case is session_id column, so it will sorted by first character 0, 2, 7, c, i, ... ?
I thought the BEFORE and AFTER were supposed to be different (sorry if I misunderstood). Thanks.
Perhaps coincidentally in @exlemor 's case the session_id column is in the same order as the time column.
So the module table list appears to be in order of time even though the patch hasn't been applied yet.
I've try it using Chrome and Mozilla, they have the same correct result (descending order by time column).
Perhaps a stupid concept - time is NOT just 19:38 from a computer point of view right? (seconds are hidden, right i.e. 19:38:01 etc and all three have different time stamps (i.e. I switched browsers for each login so they have 2-10 seconds difference between them - so they should be all showing in the same order)? (or is Joomla truly cutting off time at 2 decimals? and therefore it's normal that each browser handles the order differently...
I see in: administrator/modules/mod_logged/tmpl/default.php line 58-60:
<td>
<?php echo HTMLHelper::_('date', $user->time, Text::_('DATE_FORMAT_LC5')); ?>
</td>
So the Date column using the date format DATE_FORMAT_LC5
, it means that the datetime will hide the second: Y-m-d H:i
If we change it to DATE_FORMAT_LC6
the datetime will be show the second: Y-m-d H:i:s
Do we need to change the date format to DATE_FORMAT_LC6
at this point? :)
@exlemor If you don't mind, would you mind adding more login sessions to test it again?
Thank you for your time and patience.
@samuelagus - I have added 2 more users (5 users on 5 different browsers) and same result :/
@samuelagus - I have added 2 more users (5 users on 5 different browsers) and same result :/
Thanks for your time to try it again.
Are the same results you mean referring to this:
#46047 (comment)
after patching, you get different order results when using Safari, Vivaldi, and Google browsers ?
or this :
#46047 (comment)
before and after patching, you get the same order results ? The results should be different between before patching and after patching.
I'm noticing some strange behavior in the Logged In Users module.
Every time I reload the page, the time displayed in the module automatically updates to the current time, especially in my username row.
The time will always change to the current time every time the user reloads the page or browse to another page.
I suspect this is the cause of the problems experienced by @exlemor
I would assume that’s expected behavior when it is the time of the last activity and not the last login.
You need to check when the time is updated for a session
I would assume that’s expected behavior when it is the time of the last activity and not the last login.
Sorry for my misunderstanding. I thought that Last x Logged-in Users module displays a list of users who have recently logged in (entered through the login form and successfully logged into the website) as describe in module's description: This module shows a list of the Logged-in Users.
You need to check when the time is updated for a session
Sorry I may have misunderstood the title and description of this module.
The time updated everytime the user reload the page or browse to another page
Notice how the order is NOT the same between the 3 browsers?!
@samuelagus any reason for this?
Based on @richard67 comment: #46047 (comment)
I would assume that’s expected behavior when it is the time of the last activity and not the last login.
So I suspect the difference in the order of the list in the three browsers is due to the difference in the seconds between logins or page reload in each browser.
The most recent user who log in or reload the page will appear at the top of the list in the module in his/her own browser.
For example: When Felicia log in or reload the page, she will see her name appear at the top of the Logged-in Users module in her browser.
This behavior will also be experienced by other users when they login or reload the page in their own browser.
This behavior doesn't just occur across different browser brands.
Even if each user uses the same Chrome browser, they will experience this behavior.
This is because every time a user login or reloads the page, new session_id
will be created.
So, this patch will sort the session
db table based on the time
column in descending order, so the list in the Logged-in Users module will also be sorted by datetime in descending order.
I have tested this item 🔴 unsuccessfully on 79b0551
With the patch applied I am getting an error.
I note that the applied patch shows code different from that in the patch diff. Specifically line 42:
public function getUsers(Registry $params, CMSApplication $app, DatabaseInterface $db): mixed
is shown as
public static function getList(Registry $params, CMSApplication $app, DatabaseInterface $db)
And I think getList was removed in another PR
So the error in my Home Dashboard:
An error has occurred.
0 Cannot instantiate abstract class Joomla\Module\Logged\Administrator\Helper\LoggedHelper
Call Stack
# Function Location
1 () JROOT/libraries/src/Helper/HelperFactory.php:67
2 Joomla\CMS\Helper\HelperFactory->getHelper() JROOT/administrator/modules/mod_logged/src/Dispatcher/Dispatcher.php:89
3 Joomla\Module\Logged\Administrator\Dispatcher\Dispatcher->getLayoutData() JROOT/administrator/modules/mod_logged/src/Dispatcher/Dispatcher.php:44
4 Joomla\Module\Logged\Administrator\Dispatcher\Dispatcher->dispatch() JROOT/libraries/src/Helper/ModuleHelper.php:289
5 Joomla\CMS\Helper\ModuleHelper::renderRawModule() JROOT/libraries/src/Helper/ModuleHelper.php:160
6 Joomla\CMS\Helper\ModuleHelper::renderModule() JROOT/administrator/components/com_cpanel/tmpl/cpanel/default.php:57
7 include() JROOT/libraries/src/MVC/View/HtmlView.php:416
8 Joomla\CMS\MVC\View\HtmlView->loadTemplate() JROOT/libraries/src/MVC/View/HtmlView.php:204
9 Joomla\CMS\MVC\View\HtmlView->display() JROOT/administrator/components/com_cpanel/src/View/Cpanel/HtmlView.php:157
10 Joomla\Component\Cpanel\Administrator\View\Cpanel\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:697
11 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_cpanel/src/Controller/DisplayController.php:57
12 Joomla\Component\Cpanel\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
13 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
14 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
15 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
16 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205
17 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:304
18 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
19 require_once() JROOT/administrator/index.php:32
I have tested this item ✅ successfully on 79b0551
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46047.