Hello Magento Forum members,
we are having trouble with one of our magento 2 apps.We are using Magento CLI 2.4.4 PHP 8.1.2 running on Ubuntu 22.04.1.
Everything was working fine until yesterday when we added a few inline translations and a new product. After the cache clear we received this error:
TypeError: Cannot access offset of type string on string in /var/www/mypage/vendor/magento/framework/App/Config/Scope/Converter.php:41
Stack trace:
#0 /var/www/mypage/vendor/magento/framework/App/Config/Scope/Converter.php(22): Magento\Framework\App\Config\Scope\Converter->_setArrayValue()
#1 /var/www/mypage/vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php(108): Magento\Framework\App\Config\Scope\Converter->convert()
#2 /var/www/mypage/vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php(72): Magento\Config\App\Config\Source\RuntimeConfigSource->loadConfig()
#3 /var/www/mypage/vendor/magento/framework/App/Config/ConfigSourceAggregated.php(42): Magento\Config\App\Config\Source\RuntimeConfigSource->get()
#4 /var/www/mypage/vendor/magento/module-config/App/Config/Type/System/Reader.php(60): Magento\Framework\App\Config\ConfigSourceAggregated->get()
#5 /var/www/mypage/generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php(95): Magento\Config\App\Config\Type\System\Reader->read()
#6 /var/www/mypage/vendor/magento/module-config/App/Config/Type/System.php(395): Magento\Config\App\Config\Type\System\Reader\Proxy->read()
#7 /var/www/mypage/vendor/magento/framework/Cache/LockGuardedCacheLoader.php(136): Magento\Config\App\Config\Type\System->readData()
#8 /var/www/mypage/vendor/magento/module-config/App/Config/Type/System.php(281): Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData()
#9 /var/www/mypage/vendor/magento/module-config/App/Config/Type/System.php(207): Magento\Config\App\Config\Type\System->loadDefaultScopeData()
#10 /var/www/mypage/vendor/magento/module-config/App/Config/Type/System.php(181): Magento\Config\App\Config\Type\System->getWithParts()
#11 /var/www/mypage/vendor/magento/framework/App/Config.php(132): Magento\Config\App\Config\Type\System->get()
#12 /var/www/mypage/vendor/magento/module-backend/App/Config.php(51): Magento\Framework\App\Config->get()
#13 /var/www/mypage/vendor/magento/module-backend/App/Area/FrontNameResolver.php(109): Magento\Backend\App\Config->getValue()
#14 /var/www/mypage/vendor/magento/module-backend/Helper/Data.php(209): Magento\Backend\App\Area\FrontNameResolver->getFrontName()
#15 /var/www/mypage/vendor/magento/module-backend/App/Request/PathInfoProcessor.php(50): Magento\Backend\Helper\Data->getAreaFrontName()
#16 /var/www/mypage/generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php(95): Magento\Backend\App\Request\PathInfoProcessor->process()
#17 /var/www/mypage/vendor/magento/framework/App/Request/Http.php(148): Magento\Backend\App\Request\PathInfoProcessor\Proxy->process()
#18 /var/www/mypage/vendor/magento/framework/App/Request/Http.php(163): Magento\Framework\App\Request\Http->getOriginalPathInfo()
#19 /var/www/mypage/vendor/magento/framework/App/Request/Http.php(213): Magento\Framework\App\Request\Http->getPathInfo()
#20 /var/www/mypage/vendor/magento/framework/App/Http.php(111): Magento\Framework\App\Request\Http->getFrontName()
#21 /var/www/mypage/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#22 /var/www/mypage/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#23 {main}The frontend and backend pages are not accessible.
When i try to compile or deploy the error is also show in the command line:
Can anyone explain what we did wrong or what caused this message? How can we fix it?
Thank you very much in advance.
BR Jure
Hello @jurepribere5b6
Please edit below file:
vendor/magento/framework/App/Config/Scope/Converter.php
Replace existing function with below function:
protected function _setArrayValue(array &$container, $path, $value)
{
$segments = explode('/', $path);
$currentPointer = & $container;
foreach ($segments as $segment) {
if (!isset($currentPointer[$segment] && $segment!=null )) {
$currentPointer[$segment] = [];
}
$currentPointer = & $currentPointer[$segment];
}
$currentPointer = $value;
}Issue belongs to condition of if (!isset($currentPointer[$segment]).
Hello @Bhanu Periwal ,
thank you very much for your time. I have replaced the line and the error is gone but after setup:upgrade or compile i get this error:
PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /var/www/mypage/vendor/magento/framework/App/Config/Scope/Converter.php on line 40
I have tried to change the use "null !== $segment" inside isset but it looks like isset does not allow it.
Can this expression be done different?
Thank you in advance.
BR Jure
Hello @jurepribere5b6
In your case isset is not working.
Try below code:
protected function _setArrayValue(array &$container, $path, $value)
{
$segments = explode('/', $path);
$currentPointer = & $container;
foreach ($segments as $segment) {
if ($segment!=null && $currentPointer[$segment] !="")) {
$currentPointer[$segment] = [];
}
$currentPointer = & $currentPointer[$segment];
}
$currentPointer = $value;
}
Hello @Bhanu Periwal ,
thank you again for your reply. I have tried that and it looks like the error has gone away.
But now i get another error looks like it is connected to this issue:
Exception: Warning: Undefined array key "web" in /var/www/mypage/vendor/magento/framework/App/Config/Scope/Converter.php on line 40 in /var/www/mypage/vendor/magento/framework/App/ErrorHandler.php:61
There could be a deeper problem connected with this? Could it be that there is somwhere else the source of this problem?
Thank you in advance.
BR Jure