0

First of all, I'm new to PHP and how to write code. I installed LiteMage 1.3.14 (for Magento 1.9 but openmage) and upgraded to PHP8.2, however, I see the following frequent error codes on system.logs

Warning: Attempt to access array offset of value of type null in app/code/community/Litespeed/Litemage/Helper/Esi.php on line 557

if ($this->_esiLayoutCache['adjusted'] &&
 $this->_config->useInternalCache()) {

===========

protected function _refreshEsiBlockCache()
{
     if ($this->_esiLayoutCache['adjusted'] && $this->_config->useInternalCache()) {
        $tags = array(Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG);
        $this->_config->saveInternalCache(json_encode($this->_esiLayoutCache['blocks'], JSON_THROW_ON_ERROR), $this->_esiLayoutCache['cacheId'], $tags) ;
        $this->_esiLayoutCache['adjusted'] = false;
     }
}

May I to know how to solve it?

Thank you

1 Answer 1

1

The warning message you provided indicates an issue with accessing an array offset of a null value in the Esi.php file of the LiteMage module. This warning occurs on line 557 of the file you mentioned.

Based on the provided code snippet, it seems that the issue lies with the $this->_esiLayoutCache variable being null. When attempting to access the 'adjusted' key of the $this->_esiLayoutCache array on line 557, the warning is triggered because the variable is null.

To address this issue, you can add a null check before accessing the array offset. Here's an updated version of the code that includes the null check:

protected function _refreshEsiBlockCache()
{
     if ($this->_esiLayoutCache !== null && $this->_esiLayoutCache['adjusted'] && $this->_config->useInternalCache()) {
        $tags = array(Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG);
        $this->_config->saveInternalCache(json_encode($this->_esiLayoutCache['blocks'], JSON_THROW_ON_ERROR), $this->_esiLayoutCache['cacheId'], $tags);
        $this->_esiLayoutCache['adjusted'] = false;
     }
}

By adding the $this->_esiLayoutCache !== null condition, the code will only attempt to access the array offset if $this->_esiLayoutCache is not null, preventing the warning from being triggered.

It's worth noting that modifying the code directly may not always be the recommended approach, especially when dealing with third-party modules. It's advisable to contact the LiteMage module developers or their support for assistance in resolving this issue or to check if they have an updated version that addresses the problem.

The warning message you furnished suggests an problem with getting access to an array offset of a null fee within the Esi.Php document of the LiteMage module. This caution takes place on line 557 of the record you referred to.

Based on the provided code snippet, it appears that evidently the problem lies with the $this->_esiLayoutCache variable being null. When trying to get right of entry to the 'adjusted' key of the $this->_esiLayoutCache array online 557, the warning is triggered because the variable is null.

1
  • Hello Khunt Thank you for your great help. In fact, I asked litespeed tech about this question, and their team did not reply me. So, I'm back posting here and looking for some experts to help. Luckily you answered in such detail here. I think the problem is solved as no errors appear in the log file. Thank you again for your great help Sincerely, AJ
    – MsAJ
    Jun 18, 2023 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.