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

[FrameworkBundle] Inform the user when save_path will be ignored #31620

Merged
merged 1 commit into from Jul 8, 2019

Conversation

gnat42
Copy link
Contributor

@gnat42 gnat42 commented May 25, 2019

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no / maybe??
Deprecations? no
Tests pass? yes
Fixed tickets #31611
License MIT

When a project is created, framework.yaml or config.yml has handler_id set to ~. This uses the native php SessionHandler object which is instantiated with the save_path setting from php.ini or php-fpm.d/www.conf. If you set a save_path, it is silently ignored. When using mod_php for apache or php-fpm running as apache/nginx this is typically not a big deal (except your session files are stored someplace other than you actually wanted). However if using php-fpm and running as a non-standard user for the distro, it will fail silently. Sessions won't be saved because the setting has no effect. This throws a warning in those cases to inform the user.

It could be a BC because it changes the default configuration however fixes a 'long standing bug' if you will. Not sure what you want to do about that part.

@gnat42
Copy link
Contributor Author

gnat42 commented May 25, 2019

I haven't added tests yet because I'm not 100% sure what the best way to solve this was. This at least informs the user. However if it were possible to detect this and somehow have ini_set('session.save_path', $save_path); called that would fix the 'bug' but where to put that is a bit of a mystery. I also expect it may be useful to update the documentation related to this setting to explain why which I'd be happy to do if this was deemed the correct solution.

@chalasr chalasr added this to the 3.4 milestone May 25, 2019
@gnat42 gnat42 force-pushed the patch-session.handler_id2 branch 2 times, most recently from 01f5e22 to 267a4f7 Compare June 17, 2019 21:44
@@ -474,6 +475,12 @@ public function testNullSessionHandler()
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
}

public function testNullSessionHandlerWithSavePath()
{
$this->expectException(InvalidConfigurationException::class);
Copy link
Member

Choose a reason for hiding this comment

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

Must be converted to an annotation for tests to pass on old PHP versions.

Copy link
Member

Choose a reason for hiding this comment

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

@fabpot fabpot force-pushed the patch-session.handler_id2 branch from 267a4f7 to a090129 Compare July 8, 2019 12:54
@fabpot
Copy link
Member

fabpot commented Jul 8, 2019

Thank you @gnat42.

@fabpot fabpot merged commit a090129 into symfony:3.4 Jul 8, 2019
fabpot added a commit that referenced this pull request Jul 8, 2019
…gnored (gnat42)

This PR was squashed before being merged into the 3.4 branch (closes #31620).

Discussion
----------

[FrameworkBundle] Inform the user when save_path will be ignored

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no  / maybe??
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31611
| License       | MIT

When a project is created, framework.yaml or config.yml has handler_id set to ~. This uses the native php SessionHandler object which is instantiated with the save_path setting from php.ini or php-fpm.d/www.conf. If you set a save_path, it is silently ignored. When using mod_php for apache or php-fpm running as apache/nginx this is typically not a big deal (except your session files are stored someplace other than you actually wanted). However if using php-fpm and running as a non-standard user for the distro, it will fail silently. Sessions won't be saved because the setting has no effect. This throws a warning in those cases to inform the user.

_It could be a BC because it changes the default configuration however fixes a 'long standing bug' if you will. Not sure what you want to do about that part._

Commits
-------

a090129 [FrameworkBundle] Inform the user when save_path will be ignored
@gnat42
Copy link
Contributor Author

gnat42 commented Jul 10, 2019

thank you! @fabpot

@gnat42 gnat42 deleted the patch-session.handler_id2 branch July 10, 2019 19:10
This was referenced Jul 27, 2019
luispabon added a commit to luispabon/symfony that referenced this pull request Aug 13, 2019
nicolas-grekas added a commit that referenced this pull request Aug 22, 2019
…ill be ignored (gnat42)"

This reverts commit fea98a8, reversing
changes made to bd498f2.
nicolas-grekas added a commit that referenced this pull request Aug 22, 2019
* 3.4:
  Revert "bug #31620 [FrameworkBundle] Inform the user when save_path will be ignored (gnat42)"
  [Form][PropertyPathMapper] Avoid extra call to get config
nicolas-grekas added a commit that referenced this pull request Aug 22, 2019
* 4.3:
  Revert "bug #31620 [FrameworkBundle] Inform the user when save_path will be ignored (gnat42)"
  [Form][PropertyPathMapper] Avoid extra call to get config
  [HttpKernel] remove unused fixtures
nicolas-grekas added a commit that referenced this pull request Aug 22, 2019
* 4.4:
  Revert "bug #31620 [FrameworkBundle] Inform the user when save_path will be ignored (gnat42)"
  [Form][PropertyPathMapper] Avoid extra call to get config
  [HttpKernel] remove unused fixtures
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.

None yet

5 participants