-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC][Session] Native storage handlers should not update the global config #4208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
With the information provided in this PR, I would say B. But I want to hear @Drak point of view before taking a decision. |
@fabpot - I need time to make a reply - will be busy for two days. |
I would also say B |
Sorry, but this has turned into a long answer :) backgroundThe 'memcache' extension provides three things to PHP. It provides some The The In reality, to use native save handlers, you don't actually need to even use overviewThe basis of this PR is an assumption there are ini directives that are session specific and those which are not. This is not really the case since they are all used to configure native save handlers - the only way you can configure them since they are part of PHP's internals. analysisThe perceived issue is the PHP Ini values do not affect existing configured The intention of the The Imagine how ugly it would be if you say, "here's how to setup native memcache session, but you might additionally have to set some runtime ini-values". We cannot decide what we think is "session related" since all the ini values for each extension are the method of configuring the native handlers. Please note, solutionWhile it is true that some default behaviour is affected by ini directives, they just affect unspecified defaults when invoking certain methods.. I have updated the documentation for I would also note that all the code examples at php.net already specify explicit method invokation of conclusionI would prefer documentation. We should not neuter the classes' ability to perform - especially since it does not protect against anything anyway: Globals are globals. Let's not punish Sf2's classes for a badly designed PHP extension. The same is true for the Please note in both cases, configuration is optional and the classes do not change the global environment with default values except in one case On the plus side, the ability to configure the classes this way allows convenience like being able to configure them via Symfony2 DIC in the Sf2 full-stack framework. I would really prefer if we treat this as a documentation issue. |
I don't like setting global ini settings by I never benchmarked it but I believe that calling Proper documentation like @Drak suggested could be an alternative to |
@Drak thank you very much for your extensive feedback, below are some comments (I don't expect your reply on those, they are here for clarification - I know will we not agree) background
You probably mean "The method of configuring this save handler is via ini settings."
I think this is a bit out of scope of this PR but it is worth discussing a little. What will happen in case you have overviewWhat I meant is that some settings (eg As session handling is centralized in the Session "component" the first type should be safe to modify as nobody else will ever be impacted, the second type is not. analysis
I don't understand your reasoning here: why doesn't it apply to the session storage as well. As you have the ability to set the port in the The default port might be a bad example as it could explicitly set both when using the session storage and connecting to a server for a memcache/d instance.
I can imagine, but I find also ugly to set global values from inside the Session "component". This PR is about finding the best compromise. solution
I don't agree, see |
The compromise is already there - none of the configuration is compulsory. It put 100% control in the developers' hands. Even down to |
I have recently confirmed the intention of the ini directives with the memcached team and indeed, the ini directive are targeted just as I have explained - to configure the native handlers. For this reason, and all the reasons explained already, this PR should be closed. I understand the motivation behind this PR, but it is unfortunately, not appropriate in this context. Please also see the reference in #4255 (comment) which explains why |
This PR is not in contradiction with your statement. Using this PR, the native handlers would be configured by the ini values set in the php.ini file (as opposed to With this PR auto_start = 1 could be used for native handlers (but not for custom handler) as explained in 4255. |
Native storages have been removed in #4454 |
I think there's an issue with this change. Having memcache save_path in a config file is very useful. If you add a new server to your pool, you can modify the list in one place and release code. Keeping it in php.ini would mean logging in to X production servers and restarting apache on each one. There are some obvious workarounds for it, but IMO this makes native handler much less useful. |
@antych - I actually agree with you, but it saying that it's just as easy to create your own native driver class. I may re-release those drivers in a bundle if I get time. |
I submit this as a RFC because we can not get to an agreement on things should be done with @Drak and I would like to hear the voice of the community on this point.
Memcache will be used as an example for the discussion.
Context
When you want to use memcache to store your sesssion data, you will need to create an instance of "NativeMemcacheSessionHandler" and pass the
save_path
as argument. Thesave_path
specify the host, port and a few options (i.e. the ones passed to addServer).All the other options (i.e. the compression factor, the serializer, ...) are retrieved from the ini values.
What we do today
In order to configure the native memcache storage the
NativeMemcacheSessionHandler
class update the ini values.What I propose
I propose not to update any ini value that is gobal to all the memcache instances. To me ini values are global configs that should not be updated for a local need.
(I am ok with updating session specific settings ('memcache.session_redundancy') because those are not shared by all the memcache instances)
In order to configure the memcache native storage:
The question
Do you think:
A- It is ok to change any ini settings from inside the Session ? (The current state)
B- We should not modify any ini settings that is not strictly related to the session from inside the session. (The state after this PR)