Skip to content

[4.0] Optional session metadata, misc. session tweaks#13322

Merged
laoneo merged 14 commits intojoomla:4.0-devfrom
mbabker:4.0-no-session-metadata
Apr 11, 2018
Merged

[4.0] Optional session metadata, misc. session tweaks#13322
laoneo merged 14 commits intojoomla:4.0-devfrom
mbabker:4.0-no-session-metadata

Conversation

@mbabker
Copy link
Copy Markdown
Contributor

@mbabker mbabker commented Dec 21, 2016

Summary of Changes

This should in full decouple the requirement for session metadata. It's done by adding a new global configuration switch (default on because B/C) that when switched off features dependent on this data will need to check. Plus, some other tweaks squeezed in while testing stuff.

Summary of change:

  • New config field, if switching off metadata then the config model will also purge what data we have
  • Features dependent on session metadata adjusted:
    • Joomla\CMS\Application\CMSApplication::afterSessionStart() does not run the code to write or cleanup metadata when disabled
    • Admin mod_logged module shows a message if metadata is disabled versus a list of users
    • Admin mod_status module hides site/admin user counts if metadata is disabled
    • Site mod_whosonline module shows a message if metadata is disabled versus a count of users
    • PlgUserJoomla only interacts with the session data when the environment is set for it
    • Joomla\CMS\Table\Table::isCheckedOut() modified to account for the metadata tracking
  • Added fields to configure Redis session handler
  • Removed fields to configure the now unsupported Memcache session handler
  • Joomla\CMS\Application\CMSApplication::afterSessionStart() will no longer cause an application fatal error if writing the session metadata fails; either it'll fail again when writing the at the end of the request (if using the database handler) and the session fails to persist or the user isn't using the database handler and it really doesn't matter anyway

Testing Instructions

With this patch applied over the 4.0 branch, it should be possible to turn off writing session related metadata to the database. When using a non-database handler, the session table should always stay empty. Switching this off when enabled should clear existing metadata.

Documentation Changes Required

Note that it'll be possible for data to not always be persisted into the database, namely the session ID, client, user ID, and username. When enabled, this will cause the checked out checks to not be able to determine if a user is still logged in.

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.0-dev labels Dec 21, 2016
@brianteeman brianteeman modified the milestone: Joomla 4.0 Jun 8, 2017
@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Sep 27, 2017

Is this worth my time to pursue rebasing?

@brianteeman
Copy link
Copy Markdown
Contributor

Sorry i didnt test this as i didnt understand it and others have repeatedly stated that only experienced developers should test library changes. if only those same people would actually do that :(

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Sep 28, 2017

Well it is kind of technical in nature, and it also affects user facing features. So a mix of both would be helpful. But I'm really not interested in fighting with 9 months of merge conflicts if it's going to sit around.

@joomdonation
Copy link
Copy Markdown
Contributor

Just want to add that if people agree with the missing features when session meta data is turned off, I can test and review this PR once conflict resolved

@brianteeman
Copy link
Copy Markdown
Contributor

@mbabker looks like if you resolve the cconflicts there are at least two of us prepared to test

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Jan 5, 2018

OK this should be good to go.

@brianteeman
Copy link
Copy Markdown
Contributor

When using a non-database handler, the session table should always stay empty. Switching this off when enabled should clear existing metadata.

It clears the metadata field but leaves the record with the session_id - is that correct?

@brianteeman
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on b2dab59

Other than my question above everything still works as i would expect it to work and the module changes work as described etc


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

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Jan 5, 2018

It clears the metadata field but leaves the record with the session_id - is that correct?

Correct. The session related fields that are tracked are the session ID, time, and data.

@brianteeman
Copy link
Copy Markdown
Contributor

All seems good to me then

@joomdonation
Copy link
Copy Markdown
Contributor

It works for me, too. Just an issue with Session Save Path setting:

  1. Might be a problem with path filter but when I enter a windows path like D:\www\sessiondata , it could not be saved

  2. I guess you need to add some validation to the path to make sure it exists (like other paths). When a wrong path is entered, the application could not be started, an error like this displayed:

Warning: mkdir(): No such file or directory in D:\www\joomla4\libraries\vendor\joomla\session\src\Handler\FilesystemHandler.php on line 55
Error displaying the error page: A \Joomla\Session\SessionInterface object has not been set.: Could not create session directory "/home/abc"

* 1) The database handler is in use and the session is new
* 2) The database handler is not in use and the time is an even numbered second or the session is new
*/
if (($handler !== 'database' && ($time % 2 || $session->isNew())) || ($handler === 'database' && $session->isNew()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to be sure, when $handler !== 'database' and Track Session Metadata is off, do we still need to call $this->checkSession();?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already inside a conditional checking if the metadata is being tracked (the if statement starting at line 166)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. Thanks, see it now

@brianteeman
Copy link
Copy Markdown
Contributor

@joomdonation - enter the wrong data and you get an error message telling you that - seems fine to me.
Pretty sure that this is nothing to do with this PR though and as such is out of scope here.

@joomdonation
Copy link
Copy Markdown
Contributor

I'm not getting error. The path is saved to configuration.php and then the application could not be stared like I said

@brianteeman
Copy link
Copy Markdown
Contributor

thats what I meant. You are getting the error (just not immediately).

BUT if this happened before this PR then it is out of scope and you should create a new issue if you feel it is wrong

@joomdonation
Copy link
Copy Markdown
Contributor

Here is the screenshot after I entered a wrong path and save configuration, the site is completely broken:
application_error

@joomdonation
Copy link
Copy Markdown
Contributor

I read description of the PR and thought this is included:

Added field to configure the file path if using the file session handler

But you are correct, look like that setting was introduced before this PR

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Jan 5, 2018

Adding that setting was once in scope of this PR but at some point it got added to the repo separately, removed that note from the main description as the diff clearly shows that setting isn't being touched here now.

@joomdonation
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on b2dab59


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

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 4.0 milestone Jan 5, 2018
@ghost
Copy link
Copy Markdown

ghost commented Jan 5, 2018

Ready to Commit after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 5, 2018
@brianteeman brianteeman added this to the Joomla 4.0 milestone Jan 12, 2018
@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Feb 14, 2018

No longer interested in pursuing correct session architecture in Joomla. Bye.

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 14, 2018
@tonypartridge
Copy link
Copy Markdown
Contributor

Where are we with this? I see we got two successful tests but no merge and now conflicts?

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Apr 10, 2018

Rebased. See y'all at the next merge conflict 😉

label="CONFIG_SESSION_SETTINGS_LABEL">

<field
name="shared_session"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared sessions between front end will not be possible anymore, even when session meta data is enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a duplicate field definition. Still exists at (new) line 936. Just with all the rebasing and merging and whatnot at this point somehow it's in the form twice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, then all is fine here.

type="radio"
class="switcher"
default="0"
label="COM_CONFIG_FIELD_SHARED_SESSION_LABEL"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings should also be removed here.

@laoneo laoneo merged commit ec78aae into joomla:4.0-dev Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants