Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

JSession enhancements #1766

Closed
wants to merge 1 commit into from
Closed

JSession enhancements #1766

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 19, 2012

Fixes for memcache session store.
Fix[change] for none session store
Enhancement for JSession to add external session storage definitions
Unit tests for enhancements

Needs

Regression test for memcache and none fixes

@@ -28,6 +28,6 @@ class JSessionStorageNone extends JSessionStorage
*/
public function register()
{
ini_set('session.save_handler', 'files');
// do nothing, PHP will handle it
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually the sever configuration may have changed this to something else. Maybe we should provide JSessionStorageFiles and rename this to JSessionStorageDefault?

Copy link
Author

Choose a reason for hiding this comment

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

The problem with the current implementation is that IF the server configuration has changed it to something else, then this action breaks the server.

For example, assume that the save_handler is set to memcache:
Then session.save_path would be: sess1:11211

If you change session.save_handler to files then sessions break because the file path sess1:11211 does not exist.

If you set the save_handler to files, then you must ALSO set the save_path to something reasonable. To do one and not the other is broken.

I choose to go the route of not doing either since there is not a good way to determine a reasonable file path.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a really good point. I wonder if we can find a solution for this.

Copy link
Author

Choose a reason for hiding this comment

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

I think just removing the offending line will solve the issue. It's my guess that the only reason Joomla has this line in it is because in the ancient past there was a line somewhere in the primary JSession class which called ini_set('session.save_handler', 'somevalue') in order to redirect the session saves to itself - so as a fallback SessionNone was created which would set it back to the 'default' value - where default was assumed to be file. When we went to using session_set_save_handler, this one line of code was not removed due to an oversight.

At least, I can think of no reason WHY we would want to set session.save_handler to files today. If it was originally files, it remains files and the path is correct. If it was something else, then the save_path is likely not pointing to a directory so setting it to files will break session handling.

In either case, if SessionNone is a fallback for no other working session method, there is no need to override the default ini variable - either PHP is configured correctly and sessions will work, or it is not.

I also suspect it's an oversight mainly because it only affects the 1% of people who are using a session handling extension for PECL such as APC or Memcache and have changed their configuration. So it just never gets fixed because the number of people it affects is miniscule.

@realityking
Copy link
Contributor

The Memcache(d) changes look fine. We should look into sharing some code between the Memcache and Memcached implementations.

I'm not a big fan of the "external session storage definitions" for now I think our API using a the abstract JSessionStorage is fine. Eventually (PHP 5.4ish time) I think this should be refactored towards a DI pattern where all we need is an (instantiated) SessionHandlerInterface. Making sure the handler is supported would then fall onto the application.

@ghost
Copy link
Author

ghost commented Jan 9, 2013

I have to close this request in the next day or so and open 2 new ones, one for memcache and one for none. Thanks to Ellin, I now know how to force a different session save handler without having to go through a JSession discovery process so that code is not needed.

@ghost
Copy link
Author

ghost commented Feb 19, 2013

Closing this commit, moved memcache fixes to 1836 #1836

@ghost ghost closed this Feb 19, 2013
@ghost
Copy link
Author

ghost commented Feb 20, 2013

moved sessionNone changes to their own pull request, 1839 #1839

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant