? ? Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
28 Jul 2017

Logged user is stored in session.
Session is serialized.
JUser object has __wakeup() method which loads logged user from database
Once session is loaded, __wakeup() loads user from database
Any next attempt to get logged user via JUser::getInstance() loads user from database again because internal JUser::$instances[] cache is empty.

So, we have extra 2 DB queries on each page load.

Summary of Changes

Push the logged user loaded on session unserialize into JUser::$instances[]

Testing Instructions

Enable debug
Login in frontend.
By default there are 6 duplicated queries - see 3 attempts to load user and 3 attempts to load usergroups.

1st user load is executed on session unserialize

2nd user load is executed on current user get via JFactory::getUser()

3rd user load is executed on session unserialize called by debug plugin to display session data. Note that this user load is only executed with debug enabled.

Apply patch.

See 2 user load attempts only (previous 2nd has gone).

Besides: we should also check if load() was successfull in JUser::__wakeup(), otherwise deleted user will still exist in session.

avatar joomla-cms-bot joomla-cms-bot - change - 28 Jul 2017
Category Libraries
avatar Denitz Denitz - open - 28 Jul 2017
avatar Denitz Denitz - change - 28 Jul 2017
Status New Pending
avatar Denitz Denitz - change - 28 Jul 2017
The description was changed
avatar Denitz Denitz - edited - 28 Jul 2017
avatar Denitz Denitz - change - 31 Jul 2017
Labels Added: ?
avatar csthomas csthomas - test_item - 5 Oct 2017 - Tested successfully
avatar csthomas
csthomas - comment - 5 Oct 2017

I have tested this item successfully on 13e9bc4


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17310.

avatar FPerisa FPerisa - test_item - 26 Oct 2017 - Tested successfully
avatar FPerisa
FPerisa - comment - 26 Oct 2017

I have tested this item successfully on 13e9bc4


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17310.

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Oct 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Oct 2017

RTC after two successful tests.

avatar mbabker mbabker - change - 1 Nov 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-11-01 11:58:42
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 1 Nov 2017
avatar mbabker mbabker - merge - 1 Nov 2017

Add a Comment

Login with GitHub to post a comment