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

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

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

Comments

Projects
None yet
6 participants
@andrew-demb

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

This comment has been minimized.

Show comment
Hide comment
@xabbuh

xabbuh Oct 1, 2018

Member

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

Member

xabbuh commented Oct 1, 2018

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

@andrew-demb

This comment has been minimized.

Show comment
Hide comment
@andrew-demb

andrew-demb Oct 1, 2018

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.

andrew-demb commented Oct 1, 2018

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

This comment has been minimized.

Show comment
Hide comment
@xabbuh

xabbuh Oct 1, 2018

Member

Thanks for confirming and for creating the reproducer. 👍

Member

xabbuh commented Oct 1, 2018

Thanks for confirming and for creating the reproducer. 👍

@metamaker

This comment has been minimized.

Show comment
Hide comment
@metamaker

metamaker 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.

metamaker 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

This comment has been minimized.

Show comment
Hide comment
@stof

stof Oct 1, 2018

Member

@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 😞

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 😞

@nicolas-grekas nicolas-grekas modified the milestone: 3.4 Oct 1, 2018

nicolas-grekas added a commit that referenced this issue Oct 2, 2018

bug #28672 [DI] fix error in dumped container (nicolas-grekas)
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