Skip to content

[HttpFoundation] Fix setting session-related ini settings #27067

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

Merged
merged 1 commit into from
Apr 28, 2018

Conversation

e-moe
Copy link
Contributor

@e-moe e-moe commented Apr 26, 2018

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27011
License MIT
Doc PR n/a

Added missed option cache_expire
Fixed typo in upload_progress.min_freq
Fixed ini_set name prefix of url_rewriter.tags

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

thanks for the PR, here are some minor comments

@@ -340,21 +340,23 @@ public function setOptions(array $options)
}

$validOptions = array_flip(array(
'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cache_limiter', 'cache_expire', 'cookie_domain', 'cookie_httponly',
Copy link
Member

Choose a reason for hiding this comment

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

can you move it after cookie_domain? would make it alpha order

'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
));

foreach ($options as $key => $value) {
if (isset($validOptions[$key])) {
ini_set('session.'.$key, $value);
// All options starts with 'session.' except 'url_rewriter.tags'
$name = 'url_rewriter.tags' != $key ? 'session.'.$key : $key;
Copy link
Member

Choose a reason for hiding this comment

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

should use !==

ini_set('session.'.$key, $value);
// All options starts with 'session.' except 'url_rewriter.tags'
$name = 'url_rewriter.tags' != $key ? 'session.'.$key : $key;
ini_set($name, $value);
Copy link
Member

Choose a reason for hiding this comment

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

let's inline?
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);

'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
));

foreach ($options as $key => $value) {
if (isset($validOptions[$key])) {
ini_set('session.'.$key, $value);
// All options starts with 'session.' except 'url_rewriter.tags'
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove this comment as it just duplicates what the code tells quite evidently

$this->getStorage($options);

$this->assertEquals('a=href', ini_get('url_rewriter.tags'));
$this->assertEquals(200, ini_get('session.cache_expire'));
Copy link
Member

Choose a reason for hiding this comment

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

please use assertSame in both cases

@nicolas-grekas nicolas-grekas changed the title Fix #27011: Session ini_set bug [HttpFoundation] Fix setting session-related ini settings Apr 26, 2018

$this->getStorage($options);

$this->assertEquals('a=href', ini_get('url_rewriter.tags'));
Copy link
Member

Choose a reason for hiding this comment

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

This fails on HHVM. I suggest to skip this test on HHVM.:

if (defined('HHVM_VERSION')) {
    $this->markTestSkipped('HHVM is not handled in this test case.');
}

@e-moe
Copy link
Contributor Author

e-moe commented Apr 27, 2018

@nicolas-grekas , thanks for your review! updated

@Tobion
Copy link
Contributor

Tobion commented Apr 28, 2018

Good catch, thanks @e-moe.

@Tobion Tobion merged commit 64a0f23 into symfony:2.7 Apr 28, 2018
Tobion added a commit that referenced this pull request Apr 28, 2018
…(e-moe)

This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Fix setting session-related ini settings

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27011
| License       | MIT
| Doc PR        | n/a

Added missed option `cache_expire`
Fixed typo in `upload_progress.min_freq`
Fixed ini_set name prefix of `url_rewriter.tags`

Commits
-------

64a0f23 Fix #27011: Session ini_set bug
This was referenced Apr 30, 2018
@fabpot fabpot mentioned this pull request May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants