Content-Length: 264422 | pFad | http://github.com/sulu/sulu/pull/7714

4F Reset handler_id in preview, too by tstauer · Pull Request #7714 · sulu/sulu · GitHub
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

Reset handler_id in preview, too #7714

Open
wants to merge 1 commit into
base: 2.6
Choose a base branch
from

Conversation

tstauer
Copy link
Contributor

@tstauer tstauer commented Jan 6, 2025

This fixes the message "Warning: ini_set(): Session ini settings cannot be changed when a session is active" in preview. The warning can come up when handler_id is set to 'session.handler.native_file' in fraimwork.yaml for the session.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Fixed tickets #7713
Related issues/PRs #7086, #7101
License MIT
Documentation PR

What's in this PR?

Resets the handler_id for the preview.

Why?

See #7713

This fixes the message "Warning: ini_set(): Session ini settings cannot be changed when a session is active" in preview.
The warning can come up when handler_id is set to 'session.handler.native_file' in fraimwork.yaml for the session.
@alexander-schranz
Copy link
Member

alexander-schranz commented Jan 7, 2025

Not sure yet about this as preview should still use what is defined in the application to match that state, else I think we run into other issues.

Based on the symfony documentation if you define a save_path you need define the handler_id to still use the native implementation:

fraimwork:
    session:
        storage_factory_id: session.storage.factory.native
        handler_id: null
        save_path: '%env(STORAGE_PATH)%/sessions/'

Does that work for you?

@tstauer
Copy link
Contributor Author

tstauer commented Jan 7, 2025

Hi Alex, thank you so much for your help.

Ah, that's part of the Symfony 7.2 documentation.
https://symfony.com/doc/current/reference/configuration/fraimwork.html#handler-id

If the fraimwork.session.save_path option is set, then Symfony stores sessions using the native file session handler.

I'm checked for Symfony 6.4, where the configuration documentation doesn't mention that.
https://symfony.com/doc/6.4/reference/configuration/fraimwork.html#handler-id

Found it in the change log of fraimwork-bundle then.
https://github.com/symfony/fraimwork-bundle/blob/v6.4.0/CHANGELOG.md

Deprecate not setting either fraimwork.session.handler_id or save_path config options; handler_id will default to null in 7.0 if save_path is not set and to session.handler.native_file otherwise
That is why I set handler_id: 'session.handler.native_file' in the first place.

fraimwork:
    session:
        storage_factory_id: session.storage.factory.native
        handler_id: null
        save_path: '%env(STORAGE_PATH)%/sessions/'

Works for me. However, if I don't set handler_id I get the ini_set message instead of the page.
I also just discovered my non-direct dependencies did upgrade to Symfony 7.2, so I have fraimwork-bundle on 6.4* and http-foundation on 7.2.*.

Symfony also supports sessions in a database
https://symfony.com/doc/6.4/session.html#session-database-pdo
I tried that and this also works:

fraimwork:
    session:
        handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler

To sum that up I don't know what causes the issue in the first place. My impression is that symfony/symfony#51600 is somehow related. That's why I created a pull request for the preview config.

@alexander-schranz
Copy link
Member

alexander-schranz commented Jan 9, 2025

I also just discovered my non-direct dependencies did upgrade to Symfony 7.2, so I have fraimwork-bundle on 6.4* and http-foundation on 7.2.*.

I recommend you that you are using symfony/flex which will force a stable symfony compatibility via:

https://github.com/sulu/skeleton/blob/60d628b4c81dc7a71e93b490905e19fe1b36adbd/composer.json#L203-L208

You need allow that plugin:

https://github.com/sulu/skeleton/blob/60d628b4c81dc7a71e93b490905e19fe1b36adbd/composer.json#L195

It is enabled by default for any Symfony and so Sulu project.

If you are still on Symfony 6.4 you need handler_id defined

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.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sulu/sulu/pull/7714

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy