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

Broken service @session.attribute_bag using private method in factory #36465

Closed
VincentChalnot opened this issue Apr 16, 2020 · 1 comment
Closed

Comments

@VincentChalnot
Copy link

Symfony version(s) affected: >3.4.31

Description
The session.attribute_bag service is now broken because the previously magic Session::getAttributeBag method was added, quote : "to help with IDE autocompletion".
(At least that's the most reasonable explaination to me)

How to reproduce
Simply require the session.attribute_bag in any other service, it will throw the following error:

Call to private method Symfony\Component\HttpFoundation\Session\Session::getAttributeBag() from context ...'

Possible Solution

  • Remove service because it seems that nobody is using it apart from me?
  • Fix service definition with different method
  • Make the method public

Additional context

# From src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml:43
        <service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
            <factory service="session" method="getAttributeBag"/>
        </service>
// From src/Symfony/Component/HttpFoundation/Session/Session.php:271
    /**
     * Gets the attributebag interface.
     *
     * Note that this method was added to help with IDE autocompletion.
     *
     * @return AttributeBagInterface
     */
    private function getAttributeBag()
@VincentChalnot
Copy link
Author

Fixed in #36506

nicolas-grekas added a commit that referenced this issue Apr 21, 2020
…tion (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Fix session.attribute_bag service definition

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #36465
| License       | MIT
| Doc PR        | -

It looks like in #36063, the fact the the `getAttributeBag` method is private was forgotten. It cannot be used as the factory method. I guess we can make it public. Should it maybe marked `@internal`?

Commits
-------

76072c6 [FrameworkBundle] Fix session.attribute_bag service definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants