{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/26153","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/26153/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/26153/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/26153/events","html_url":"https://github.com/symfony/symfony/issues/26153","id":296444325,"number":26153,"title":"Missing argument / circular logic when defining custom session handler proxy","user":{"login":"dariodevito","id":9873176,"avatar_url":"https://avatars0.githubusercontent.com/u/9873176?v=4","gravatar_id":"","url":"https://api.github.com/users/dariodevito","html_url":"https://github.com/dariodevito","followers_url":"https://api.github.com/users/dariodevito/followers","following_url":"https://api.github.com/users/dariodevito/following{/other_user}","gists_url":"https://api.github.com/users/dariodevito/gists{/gist_id}","starred_url":"https://api.github.com/users/dariodevito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dariodevito/subscriptions","organizations_url":"https://api.github.com/users/dariodevito/orgs","repos_url":"https://api.github.com/users/dariodevito/repos","events_url":"https://api.github.com/users/dariodevito/events{/privacy}","received_events_url":"https://api.github.com/users/dariodevito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-12T16:43:49Z","updated_at":"2018-02-12T19:20:13Z","closed_at":null,"author_association":"NONE","body":"| Q                | A\r\n| ---------------- | -----\r\n| Bug report?      | yes\r\n| Feature request? | no\r\n| BC Break report? | no\r\n| RFC?             | no\r\n| Symfony version  | 2.8.1\r\n\r\n\r\nI have been trying to register a custom session handler proxy in order to encrypt / decrypt session data. Seems fairly straight forward and I've been using the example provided here https://symfony.com/doc/2.8/session/proxy_examples.html\r\n\r\nHowever if I define the service as per the example, I get a fatal error as the class construct is expecting an instance of the session handler as an argument:\r\n\r\n```\r\nType error: Too few arguments to function CoreBundle\\Session\\EncryptedSessionHandlerProxy::__construct(), 0 passed in\r\n```\r\n\r\nThis implies that I need to pass the session handler to the service as an argument however, if I do this then I receive the following error:\r\n\r\n```\r\nCircular reference detected for service \"app.session_handler\", path: \"app.session_handler -> session -> session.storage.native -> app.session_handler\".\r\n```\r\n\r\nMy yaml config looks as follows:\r\n\r\n```\r\n//  app/config/services.yml\r\nservices:\r\n    app.session_handler:\r\n        class: CoreBundle\\Session\\EncryptedSessionHandlerProxy\r\n        arguments:\r\n            - \"@session\"\r\n```\r\nOR\r\n```\r\n//  app/config/services.yml\r\nservices:\r\n    app.session_handler:\r\n        class: CoreBundle\\Session\\EncryptedSessionHandlerProxy\r\n        arguments:\r\n            - \"@app.session_handler\"\r\n```\r\n\r\n```\r\n//  app/config/config.yml\r\nsession:\r\n    handler_id: app.session_handler\r\n```\r\n\r\nClass is defined as follows:\r\n\r\n```\r\nnamespace CoreBundle\\Session;\r\n\r\nuse Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy;\r\n\r\n/**\r\n * Proxy to encrypt / decrypt session data\r\n */\r\nclass EncryptedSessionHandlerProxy extends SessionHandlerProxy\r\n{\r\n    private $key;\r\n\r\n    /**\r\n     * Construct\r\n     *\r\n     * @param SessionHandlerInterface $handler\r\n     */\r\n    public function __construct(SessionHandlerInterface $handler)\r\n    {...\r\n```\r\n\r\nThe errors seem logical however I am unsure how to pass the session handler in via the service config? The implementation is the docs example doesn't appear correct and I've looked through the codebase to identify a similar implementation but can't find anything.\r\n\r\nAny advise on the correct implementation / confirmation if this is a bug would be of much help. \r\n\r\nThanks "},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/365032327","html_url":"https://github.com/symfony/symfony/issues/26153#issuecomment-365032327","issue_url":"https://api.github.com/repos/symfony/symfony/issues/26153","id":365032327,"user":{"login":"dmaicher","id":921145,"avatar_url":"https://avatars3.githubusercontent.com/u/921145?v=4","gravatar_id":"","url":"https://api.github.com/users/dmaicher","html_url":"https://github.com/dmaicher","followers_url":"https://api.github.com/users/dmaicher/followers","following_url":"https://api.github.com/users/dmaicher/following{/other_user}","gists_url":"https://api.github.com/users/dmaicher/gists{/gist_id}","starred_url":"https://api.github.com/users/dmaicher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmaicher/subscriptions","organizations_url":"https://api.github.com/users/dmaicher/orgs","repos_url":"https://api.github.com/users/dmaicher/repos","events_url":"https://api.github.com/users/dmaicher/events{/privacy}","received_events_url":"https://api.github.com/users/dmaicher/received_events","type":"User","site_admin":false},"created_at":"2018-02-12T19:20:13Z","updated_at":"2018-02-12T19:20:13Z","author_association":"CONTRIBUTOR","body":"@dariodevito Normally the alias is `session.handler`\r\n\r\nSo this here should work **without the** `handler_id: app.session_handler` config:\r\n\r\n```yml\r\napp.encrypt_session_handler:\r\n    class: CoreBundle\\Session\\EncryptedSessionHandlerProxy\r\n    decorates: \"session.handler\"\r\n    arguments:\r\n        - \"@app.encrypt_session_handler.inner\"\r\n```\r\n"}}
{"actor":{"display_login":"dmaicher"}}