S
S
Sergei Iamskoi2019-07-25 09:38:23
Yii
Sergei Iamskoi, 2019-07-25 09:38:23

What's with the strange behavior of the component?

There is such a wrapper in Bootstrap.php :

$container->setSingleton(Queue::class, static function () {
            return Yii::$app->queue;
        });

If you execute the code, it will fail with the 500th error that Yii::$app->queue is null;
If we put a breakpoint only on the return ... line, then we will see that Yii::$app->queue is indeed null and we get the 500th.
If we put a breakpoint on the $container line, then we see that Yii::$app->queue is not empty and (!!!) the program unexpectedly continues to run without crashing, everything works out.
But! If we put a breakpoint on $container and on return, then we will see that Yii::$app->queue in return has become non-empty and everything works the same way.
What is wave-particle duality?
Moreover, there are several such wrappers for components above, but only this one has such behavior. The location does not affect the transfer to main.php either. Just calling Yii::$app->queue instead of DI at that point in the program works great.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei Iamskoi, 2019-07-25
@syamskoy

Solution: the problem is in the component and container of the same name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question