You had this error because you are using an obsolete Magento version, this was fixed in Magento 2.3.7 and 2.4.0.
To resolve this problem, you can fix this error separately or upgrade the Magento version to at least 2.3.7 or 2.4.0.
To fix this error separately, replace the original method from
public function getWord()
{
$sessionData = $this->session->getData($this->getFormIdKey(self::SESSION_WORD));
return time() < $sessionData['expires'] ? $sessionData['data'] : null;
}
to
public function getWord()
{
$sessionData = $this->session->getData($this->getFormIdKey(self::SESSION_WORD));
$word = null;
if (isset($sessionData['expires'], $sessionData['data']) && time() < $sessionData['expires']) {
$word = $sessionData['data'];
}
return $word;
}
There are several approaches to applying this fix:
- Override the original method in Magento core codebase using
Plugin
(Interceptor) in a custom module. This approach is better than the preference
approach below in most cases but in your particular case, because as a new Magento version of your current version, the original class (file) will be changed to use a new method getWords
method instead the current getWord() method, this approach and
preference` approach are equal.
- Override the original method in Magento core codebase using
preference
in a custom module.
- Override the original method in Magento core codebase using a patch file based on the change. Because you are using an obsolete Magento version, if you go with this approach, I recommend you run the patch from the command line (manually or via deploy tool) instead of via a composer patch plugin because you may get unexpected issues.
- Edit the original method in Magento core codebase directly. (This approach is not recommended because whenever you upgrade to a new Magento version your changes in Magento core codebase will be lost).
Since you are using an obsolete Magento version, I recommend you upgrade Magento version asap to get more features and get more quality fixes, especially in keeping your site safe. I'll write more information about new Magento versions:
- Currently, the latest version of Magento is 2.4.6.
- Magento version 2.3 reached end of support in September 2022.
- Magento versions from 2.4.0 to 2.4.3 reached end of support in November 28, 2022.
** End of support includes both end of quality fixes and end of security fixes.