Skip to content
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

[2.1][FrameworkBundle] Allow configuration of session garbage collection #3659

Merged
merged 3 commits into from Mar 26, 2012
Merged

[2.1][FrameworkBundle] Allow configuration of session garbage collection #3659

merged 3 commits into from Mar 26, 2012

Conversation

ghost
Copy link

@ghost ghost commented Mar 21, 2012

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2171
Todo: -

@@ -90,6 +90,9 @@
<!-- end of deprecated attributes -->
<xsd:attribute name="cache-limiter" type="xsd:string" />
<xsd:attribute name="auto-start" type="xsd:boolean" />
<xsd:attribute name="gc-maxlifetime" type="xsd:integer" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should xsd:string (to allow %lifetime%)

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry, but I dont follow. Also please note this is very important that this lifetime is not confused with other lifetimes (like cookie lifetime) for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

The question is: do we want to allow integers only or would parameters be fine also ("lifetime" is a generic name above)

Copy link
Author

Choose a reason for hiding this comment

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

It's kind of terrible because it seems PHP's configuration ini takes strings and casts them as required which is kind of nasty. If you set something boolean when you retrieve the values you get back string integers on ini_get(). So the question is how much validation do we want, since these would have to be "integer strings" if you catch my drift.

I think if Symfony2 doesnt allow %string% replacements for integer fields, then that's something that should be looked at quite honestly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really get your point here. My concern is not with .ini or sf2 but with the xsd only.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, but it would mean for string replacements, everything has to be marked as string, which means you lose a big part of the validation.

Copy link
Member

Choose a reason for hiding this comment

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

@Drak The validation is already performed properly by the Configuration class, using the processed value (meaning that you can validate as an integer there and use %lifetime% to use a parameter). The XSD validation occurs way too early to be able to be strict (which is also why we cannot use required in the XSD for required params for instance because they are required in one config file, not in each config file)

Copy link
Author

Choose a reason for hiding this comment

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

OK so basically all fields can/should be xsd:string and it's sorted out in the configuration class?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, XSD files are not used to perform the actual validation as the Config system is far more powerful for this. The main goal of providing an XSD is for IDE auto-completion for guys choosing XML for their app-level config (and they are probably a minority). Thus, if an error occurs during the XSD validation, the exception thrown to the user is pretty cryptic which is generally a WTF ("what does this stuff mean ?")
I'm wondering if it makes sense to continue maintaining them.

Copy link
Author

Choose a reason for hiding this comment

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

@stof - thanks for the clarification, I'll make the necessary changes this PR.

@ghost
Copy link
Author

ghost commented Mar 21, 2012

@fabpot - this PR is ready for merge. It basically allows configuration of some session ini values that are necessary in controlling the session behaviour.

@dlsniper
Copy link
Contributor

@Drak shouldn't all the options here: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L266 be available for configuration, or am I just reading the source wrong and they already are?

In this case should I make a separate PR to cover the rest or could you do it in this one?

@fabpot
Copy link
Member

fabpot commented Mar 23, 2012

@Drak: the discussion is the ticket is very interesting and I think it should be part of a cookbook in the documentation. Can you take care of that before I merge this PR? Thanks.

@ghost
Copy link
Author

ghost commented Mar 25, 2012

@fabpot - yes - it's on the todo list. Will update this PR when done.

@ghost
Copy link
Author

ghost commented Mar 26, 2012

@fabpot - this is ready for merging, the documentation is done (the PR is in but I'll tweak it, but no need to wait to merge this PR). I will also add something extra to cookbook (I wrote docs for the component).

fabpot added a commit that referenced this pull request Mar 26, 2012
Commits
-------

cdba4cf [FrameworkBundle] Change XSD to allow string replacements on session args.
52f7955 [FrameworkBundle] Remove default from gc_* session configuration keys.
749593d [FrameworkBundle] Allow configuration of session garbage collection for session 'keep-alive'.

Discussion
----------

[2.1][FrameworkBundle] Allow configuration of session garbage collection

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2171
Todo: -

---------------------------------------------------------------------------

by drak at 2012-03-21T21:56:20Z

@fabpot - this PR is ready for merge.  It basically allows configuration of some session ini values that are necessary in controlling the session behaviour.

---------------------------------------------------------------------------

by dlsniper at 2012-03-21T22:57:18Z

@Drak shouldn't all the options here: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L266 be available for configuration, or am I just reading the source wrong and they already are?

In this case should I make a separate PR to cover the rest or could you do it in this one?

---------------------------------------------------------------------------

by fabpot at 2012-03-23T14:56:22Z

@Drak: the discussion is the ticket is very interesting and I think it should be part of a cookbook in the documentation. Can you take care of that before I merge this PR? Thanks.

---------------------------------------------------------------------------

by drak at 2012-03-25T15:32:59Z

@fabpot - yes - it's on the todo list.  Will update this PR when done.

---------------------------------------------------------------------------

by drak at 2012-03-26T19:45:13Z

@fabpot - this is ready for merging, the documentation is done (the PR is in but I'll tweak it, but no need to wait to merge this PR).  I will also add something extra to cookbook (I wrote docs for the component).
@fabpot fabpot merged commit cdba4cf into symfony:master Mar 26, 2012
@dlsniper
Copy link
Contributor

@Drak please see my above comment, #3659 (comment) , I can start working on a PR for this if you want, should be fairly straight forward.

What do you think?

@ghost
Copy link
Author

ghost commented Mar 28, 2012

@dlsniper I have no strong objections, except that some of the options, in the context of FrameworkBundle do not make sense to configure - for example, auto_start really does need to be switched off at all times - the reason is, we only want to explicitly start sessions. use_cookies and always_use_cookies (from memory sorry if it's wrong), really always need to be on. Remember, these configuration option in the Component make sense for standalone use, but it's within the context of FrameworkBundle where options may not work.

Sorry for my late reply, just had a lot on my plate.

@dlsniper
Copy link
Contributor

@Drak yeah, no worries. I know for example we were forced to use auto_start in our application because of strange behavior in the previous implementation of session (before your changes) hence my asking out it.

Thank you again for your time and the great contributions you've made for Sf2 so far :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants