LiteSpeed Cache issue in PrestaShop 1.7.8+

pkcf

New Member
#1
Hello,

PrestaShop in version 1.7.8+ introduced some changes which caused LiteSpeed Cache module to break.
Tested on clean PrestaShop 1.7.8.5 and LiteSpeed Cache 1.4.0 module and PHP 7.1, 7.2, 7.4

After activating the cache, the product page no longer works. Error 500 appears:
(1/1) FatalThrowableError
Type error: Argument 3 passed to HookCore::callHookOn() must be of the type array, null given, called in /home/user/public_html/prestashop/classes/Hook.php on line 944


Additionally, in debug mode, the LiteSpeed Cache Configuration tab doesn't work:
Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: Undefined index: id" at /home/user/public_html/prestashop/classes/helper/HelperForm.php line 121


The problem was reported in PrestaShop's Github, unfortunately the issue was closed, "since it's not a PS Core issue".
https://github.com/PrestaShop/PrestaShop/issues/27585

so i figured I will report it here.
 

pkcf

New Member
#6
Thanks for your help. This indeed fixes the issue on my clean installation. I will forward this information to my client and I am assuming this will work for him as well
 

serpent_driver

Well-Known Member
#10
It means what it means. If neither PrestaShop nor Cache Plugin is updated for a long time and nobody is willing to update, then you can't expect that the issue will resolve itself. Sorry, but this is sadly reality.

I can't speak for LiteSpeed, but I think an update will be released first if PrestaShop will be PHP 8.x ready.
 
#11
It means what it means. If neither PrestaShop nor Cache Plugin is updated for a long time and nobody is willing to update, then you can't expect that the issue will resolve itself. Sorry, but this is sadly reality.

I can't speak for LiteSpeed, but I think an update will be released first if PrestaShop will be PHP 8.x ready.
Well, it will be simple solution regarding LiteSpeed - stop using/paying for the Enterprise and just use another cache solution.

Seeems like this is left unresolved ...

Also, seems like LS admin know the prodblem is there, but the comment module have no issue used with any other modules, only with Litespeed?
 

serpent_driver

Well-Known Member
#12
You can't compare any other module with LiteSpeed cache module. This module is only a control panel to tell the web server (the web server caches, but not the module) what he has to do. Anyway, you are basically right. It is up to LiteSpeed to fix an issue, but LiteSpeed can't consider every 3rd party module.
 
#13
Not comparing. :)

>> LiteSpeed can't consider every 3rd party module.

In this case Product Comment Module is not a 3rd party module .... at least should LScache with standard modules.
 
Last edited:

NiteWave

Administrator
#15
Additionally, in debug mode, the LiteSpeed Cache Configuration tab doesn't work:
Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: Undefined index: id" at /home/user/public_html/prestashop/classes/helper/HelperForm.php line 121
this issue has a fix or workaround -- tested on PrestaShop 1.7.8.7 + PHP 7.4.30

the code:
https://github.com/PrestaShop/PrestaShop/blob/develop/classes/helper/HelperForm.php
from line 113 to 127:
Code:
switch ($params['type']) {
    case 'switch':
        $switch_values = $params['values'];
        if (!empty($params['values'])) {
            foreach ($switch_values as $k => $value) {
                if (!isset($value['label'])) {
                    $default_key = (int) $value['value'] ? 1 : 0;
                    $defautl_label = $default_switch_labels[$value['id']] ?? $default_switch_values[$default_key]['label'];
                    $this->fields_form[$fieldset_key]['form']['input'][$key]['values'][$k]['label'] = $defautl_label;
                }
            }
        } else {
            $this->fields_form[$fieldset_key]['form']['input'][$key]['values'] = $default_switch_values;
        }
        break;
the message "Notice: Undefined index: id" is from this line:
Code:
                    $defautl_label = $default_switch_labels[$value['id']] ?? $default_switch_values[$default_key]['label'];
if change it to
Code:
                    if(isset($value['id']) && isset($default_switch_labels[$value['id']]))
                        $defautl_label = $default_switch_labels[$value['id']];
                    else
                        $defautl_label = $default_switch_values[$default_key]['label'];
or simply
Code:
                    $defautl_label = $default_switch_values[$default_key]['label'];
or turn off debug mode, the exception is gone and LiteSpeed Cache Configuration tab works again.
 
Top