8000 [DI] Error on dumped container for inlined services · Issue #28658 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Error on dumped container for inlined services #28658

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

Closed
andrew-demb opened this issue Oct 1, 2018 · 5 comments
Closed

[DI] Error on dumped container for inlined services #28658

andrew-demb opened this issue Oct 1, 2018 · 5 comments

Comments

@andrew-demb
Copy link
Contributor
andrew-demb commented Oct 1, 2018

Symfony version(s) affected: 3.4.16

Description
After update to 3.4.16 version inlined dependencies (in my case with circular dependencies) dumped with use $this->privates value from the container for return as service.
But every value from $this->privates is a boolean.

How to reproduce

git clone https://github.com/andrew-demb/sf-di-3.4.16-circular-reference-dump.git
cd sf-di-3.4.16-circular-reference-dump/
php bug.php

Additional context
Repository with reproduce script: https://github.com/andrew-demb/sf-di-3.4.16-circular-reference-dump

This PR #28388 represents a change for PhpDumper to use privates in dumped container.

Some pieces from cached container:

class ProjectServiceContainer extends Container
{
    private $parameters;
    private $targetDirs = array();

    public function __construct()
    {
        $this->services = array();
        $this->methodMap = array(
            'service_one' => 'getServiceOneService',
            'service_two' => 'getServiceTwoService',
        );
        $this->privates = array(
            'service_one' => true,
            'service_two' => true,
        );

        $this->aliases = array();
    }
// ...
    protected function getServiceTwoService()
    {
        $a = ${($_ = isset($this->services['service_one']) ? $this->services['service_one'] : $this->getServiceOneService()) && false ?: '_'};

        if (isset($this->privates['service_two'])) {
            return $this->privates['service_two'];
        }

        return $this->services['service_two'] = new \ArrayObject(array('source' => $a));
    }

YAML config

services:
    service_one:
        class: ArrayObject
        calls:
            - [ offsetSet, ['sv', '@service_two'] ]

    service_two:
        class: ArrayObject
        arguments:
            -
                source: '@service_one'
@xabbuh
Copy link
Member
xabbuh commented Oct 1, 2018

Thanks for reporting. This is the same as #28657, right?

@andrew-demb
Copy link
Contributor Author

Thanks for reporting. This is the same as #28657, right?

It seems that yes. Every call for $this->private will return bool instead of instance of service.

@xabbuh
Copy link
Member
xabbuh commented Oct 1, 2018

Thanks for confirming and for creating the reproducer. 👍

@dmytro-y-dev
Copy link
dmytro-y-dev commented Oct 1, 2018

Same for our codebase, got the problem today morning (meh, Monday mood). Temporary locked Symfony version to 3.4.15, but I hope that this will be solved asap, this is critical issue for us.

@stof
Copy link
Member
stof commented Oct 1, 2018

@nicolas-grekas the fact that we have $this->privates both in 3.x and 4.x but for different purposes makes it hard to avoid such issues when switching between branches. That's not the first time 😞

A138 @nicolas-grekas nicolas-grekas modified the milestone: 3.4 Oct 1, 2018
nicolas-grekas added a commit that referenced this issue Oct 2, 2018
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] fix error in dumped container

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28658
| License       | MIT
| Doc PR        | -

(test case on its way)

Commits
-------

2d0aba6 [DI] fix error in dumped container
emodric added a commit to netgen-layouts/layouts-core that referenced this issue Oct 2, 2018
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

6 participants
0