-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(v3.4.16) affected:
Description
The error occurred when we try to add twig extension:
$instance->addExtension(${($_ = isset($this->services['li_cms.twig.cms_extension']) ? $this->services['li_cms.twig.cms_extension'] : $this->getLiCms_Twig_CmsExtensionService()) && false ?: '_'});
If to be more precise - method: $this->getLiCms_Twig_CmsExtensionService()
This method should return the instance of Twig_ExtensionInterface but boolean was returned.
We found difference in method -getLiCms_Twig_CmsExtensionService- between symfony version -
3.4.15 and 3.4.16:
In version 3.4.15
protected function getLiCms_Twig_CmsExtensionService()
{
$a = ${($_ = isset($this->services['li_cms.service.cms_service']) ? $this->services['li_cms.service.cms_service'] : $this->getLiCms_Service_CmsServiceService()) && false ?: '_'};
if (isset($this->services['li_cms.twig.cms_extension'])) {
return $this->services['li_cms.twig.cms_extension'];
}
return $this->services['li_cms.twig.cms_extension'] = new \LI\CmsBundle\Twig\CmsExtension($a);
}
and in version 3.4.16
protected function getLiCms_Twig_CmsExtensionService()
{
$a = ${($_ = isset($this->services['li_cms.service.cms_service']) ? $this->services['li_cms.service.cms_service'] : $this->getLiCms_Service_CmsServiceService()) && false ?: '_'};
if (isset($this->privates['li_cms.twig.cms_extension'])) {
return $this->privates['li_cms.twig.cms_extension'];
}
return $this->services['li_cms.twig.cms_extension'] = new \LI\CmsBundle\Twig\CmsExtension($a);
}
as you can see in first example we take li_cms.twig.cms_extension
from $this->services array and the second example - we take from $this->privates.
The problem is:
li_cms.twig.cms_extension - in $this->privates array exists and it will return true:
so this condition will be met:
if (isset($this->privates['li_cms.twig.cms_extension'])) {
return $this->privates['li_cms.twig.cms_extension'];
}
in this case function getLiCms_Twig_CmsExtensionService()
- will return true instead of necessary class.