Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@VincentChalnot

Description

@VincentChalnot
Issue body actions

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()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.