di icon indicating copy to clipboard operation
di copied to clipboard

Container doesn't resolve properties of already built instances after their state reset

Open alamagus opened this issue 3 years ago • 2 comments

What steps will reproduce the problem?

Run yiisoft/demo via RR(yiisoft/yii-runner-roadrunner) 1st request is handled properly, after which StateResetter::reset() is invoked in subsequent requests container returns instances with unresolved properties

Example for subsequent requests:

What is the expected result?

Screenshot from 2022-08-10 09-04-14

What do you get instead?

Screenshot from 2022-08-10 09-05-57

Additional info

Q A
Version 1.1.0
PHP version 8.1.2
Operating system Ubuntu 22.04

alamagus avatar Aug 10 '22 06:08 alamagus

Seems, problem here.

On first request container parse definitions and convert their to objects, but on reset this is not happening.

vjik avatar Aug 11 '22 07:08 vjik

as a temporary solution for anyone who's running demo app on RR, amend reset:

'reset' => function (\Psr\Container\ContainerInterface $container) use ($params) {
    /** @var WebView $this */
    $this->clear();

    $resolvedParams = [];
    foreach ($params['yiisoft/view']['parameters'] as $id => $value) {
        $resolvedParams[$id] = $value instanceof \Yiisoft\Definitions\Reference ? $value->resolve($container) : $value;
    }
    $this->setParameters($resolvedParams);
}

alamagus avatar Aug 11 '22 10:08 alamagus