? ? Success

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
22 Jun 2016

Summary of Changes

To try and sum things up:

  • JSession can now lazy start a session; calls to get(), set(), has(), and clear() will start the session if it hasn't explicitly been started previously
  • The application classes are restructured to not explicitly start the session; this defers the point JSession::start() is called from the application constructors to one of the first actions done after $app->execute() is called. The advantage here is that now sessions are started after the application has been instantiated and set to JFactory::$application.
  • The logic for purging of session metadata is altered so that this step only occurs if the database session handler is not in use and it is now executed as part of the onAfterRender event instead of when the session is originally started; garbage collection will occur for the database session handler as part of the PHP session API
  • JApplicationCms::checkSession() now optionally accepts the JSession object that should be checked and this will be a mandatory argument as of 4.0. This method is called as part of the afterSessionStart event which may occur without a session object stored to JFactory.
  • The afterSessionStart event now includes the JSession object for which the session was started for as an argument of the event, this should be used instead of fetching the session from JFactory
  • Adjustments to the database session handler:
    • JSessionStorageDatabase is dependent on the application to insert the session record into the database table, the logic is added to the write() method to remove this dependency
    • Garbage collection when the database session store is used is deferred to the end of the request cycle to help prevent a request failure solely because expired session records are being purged. As explained in the PHP documentation the gc() method is called when the session is started.
    • JApplicationCms::checkSession() is adjusted to only manipulate the time column when not using the database session handler to preserve the record's integrity when written by the session API

Testing Instructions

1) Download the branch from https://github.com/mbabker/joomla-cms/archive/refactor-session-metadata-coupling.zip
2) Install Joomla; sessions in the installation application should continue to function correctly
3) Use Joomla normally; sessions should continue to function correctly
4) With the database session handler enabled, JApplicationCms::checkSession() should only be executed when the session is new. As this is only ensuring the extra metadata is present in the database, it is not required for every page load. All requests after the session is started will have the record in the database updated by the session handler only (or any place making an explicit query to the #__session database table). As well, the new JApplicationCms::cleanupSessionMetadata() method should never be called.
5) With any other session handler enabled, JApplicationCms::checkSession() should only be called if the session is new or the time is an even numbered second. The new JApplicationCms::cleanupSessionMetadata() method should be called when the onAfterRender event is triggered and the delete query should only run when the time is an even numbered second.

avatar mbabker mbabker - open - 22 Jun 2016
avatar mbabker mbabker - change - 22 Jun 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jun 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jun 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 23 Jun 2016
Category Libraries Unit Tests
avatar brianteeman brianteeman - change - 23 Jun 2016
Labels
avatar pritalpatel
pritalpatel - comment - 1 Jul 2016

I have followed the steps provided. I successfully tested 1-3 steps. But not able to understand 4th and 5th step clearly. I am sure this is me who don’t understand as I don’t much familiar with joomla framework so far.

Thank you. ?


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

avatar mbabker
mbabker - comment - 20 Jul 2016

Look, I know this is tricky as all can be to properly test, but there are major logic and workflow fixes introduced here that are somewhat needed to break some existing bad practices. Some tests here would be appreciated...

avatar mbabker
mbabker - comment - 13 Aug 2016

Is this going anywhere or can I close for lack of interest?

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Aug 2016

from my part i find all your PR interresting but because of gsoc project lack of time ATM.

avatar mbabker
mbabker - comment - 12 Sep 2016

Out of sync yet again and apparently too complex for the user base. I'm done.

avatar mbabker mbabker - change - 12 Sep 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-09-12 20:50:39
Closed_By mbabker
avatar PhilETaylor
PhilETaylor - comment - 13 Sep 2016

This has only been open 4 months, even some simpler PRs have been open since Aug 18, 2014 ;-)

avatar mbabker
mbabker - comment - 13 Sep 2016

After the discussion yesterday I'm keeping my PRs limited to things that a user can click in the backend after installing a patch with patch tester since apparently requesting testing on highly technical matters such as this is asking for too much.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Sep 2016

please don't close your PR michael, i think most of them are important.

i don't have always time to test all of them, but i try to test them when possible.

avatar mbabker mbabker - change - 13 Sep 2016
Status Closed New
Closed_Date 2016-09-12 20:50:37
Closed_By mbabker
avatar mbabker mbabker - change - 13 Sep 2016
Status New Pending
avatar mbabker
mbabker - comment - 13 Sep 2016

I will try this one last time. Key points here:

  • The database handler has a hardcoded dependency to the record being inserted by the application, this is now fixed
  • The database metadata cleanup operation is differed to the end of the request cycle and error trapped to prevent the user from getting the error page simply because this operation failed
  • Session starting is deferred to a point after the application is stored to the factory; if the session fails to start for whatever reason this should put the user in an error page instead of the "Application Instantiation Error" stuff showing
  • One must explicitly call $session->start() to correctly start the session right now; similar to other parts of the API that lazy load, the session can now do the same
  • The session start event is reliant on global state (namely having a JSession object stored to the factory); this is resolved by passing the event dependency through the dispatcher
  • Because of our metadata tracking mechanisms, right now the loadSession() method is also performing session garbage collection when the database handler is in use; this is a waste of cycles as the underlying PHP API has mechanisms to perform garbage collection AND handles expired sessions just fine without us beating it to the punch

These are all deep rooted architectural issues that need to be addressed and the only way to do so is testing through these technically heavy patches.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Sep 2016
  • applied patch
  • in frontend deleted all cookies to start a new session
  • refreshed the page. Result: 500 error

image

Same error in the admin
image

avatar mbabker
mbabker - comment - 13 Sep 2016

Fixed. That last merge didn't go well at all.

avatar andrepereiradasilva andrepereiradasilva - test_item - 13 Sep 2016 - Tested successfully
avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Sep 2016

I have tested this item successfully on 42fe67a

1) Download the branch from https://github.com/mbabker/joomla-cms/archive/refactor-session-metadata-coupling.zip
2) Install Joomla; sessions in the installation application should continue to function correctly

OK

3) Use Joomla normally; sessions should continue to function correctly

OK

4) With the database session handler enabled, JApplicationCms::checkSession() should only be executed when the session is new. As this is only ensuring the extra metadata is present in the database, it is not required for every page load. All requests after the session is started will have the record in the database updated by the session handler only (or any place making an explicit query to the #__session database table). As well, the new JApplicationCms::cleanupSessionMetadata() method should never be called.

OK. Added $this->enqueueMessage('checkSession called', 'notice'); in JApplicationCms::checkSession() to confirm.

5) With any other session handler enabled, JApplicationCms::checkSession() should only be called if the session is new or the time is an even numbered second. The new JApplicationCms::cleanupSessionMetadata() method should be called when the onAfterRender event is triggered and the delete query should only run when the time is an even numbered second.

Didn't test don't have other session handler to test.


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

avatar mbabker
mbabker - comment - 13 Sep 2016

Should be able to use the filesystem (PHP, None, whatever it's called in the UI these days).

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Sep 2016

ok of course! ? will check that

avatar dgt41 dgt41 - test_item - 13 Sep 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 13 Sep 2016

I have tested this item successfully on 42fe67a

PHP, Database
No memcache


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

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Sep 2016

Works with PHP as session handler too, with this handler the notice added appears somewhat random as supposed (should only be called [...] or the time is an even numbered second).

avatar zero-24 zero-24 - change - 14 Sep 2016
Status Pending Ready to Commit
avatar zero-24 zero-24 - change - 14 Sep 2016
Labels Added: ?
avatar wilsonge wilsonge - change - 18 Sep 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-09-18 15:40:27
Closed_By wilsonge
avatar wilsonge wilsonge - change - 18 Sep 2016
Labels Removed: ?
avatar infograf768
infograf768 - comment - 20 Sep 2016

Hmm, @mbabker

Could this be the reason why I get a PHP Warning?

See #12108

avatar infograf768
infograf768 - comment - 20 Sep 2016

Reverting this PR solves the issue

avatar brianteeman
brianteeman - comment - 21 Sep 2016

This should not have been merged into 3.6.3 it was not a bug fix and should have waited for 3.7

avatar mbabker
mbabker - comment - 21 Sep 2016

Wouldn't have mattered what branch it went into. Still would've hit the same bugs because some condition's not going to be tested through normally and it's going to result in someone getting something broken. So, I'm not pushing it anymore. We'll just stick with the broken global state and default structures we have now.

Add a Comment

Login with GitHub to post a comment