0

I've got a problem with PrestaShop's site. After I add product to comparison and following a link to the page it shows 500 server error. In server logs:

ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML, referer: https://svdd.ru/products-comparison

PHP Notice:  Undefined index: search_query in /var/www/svddru/data/www/svdd.ru/cache/smarty/compile/9e/0b/2e/9e0b2eed3cabe548854f824a36411cf7b41c2feb.file.blocksearch-top.tpl.php on line 37, referer: https://svdd.ru/products-comparison

PHP Notice:  Trying to get property of non-object in /var/www/svddru/data/www/svdd.ru/cache/smarty/compile/9e/0b/2e/9e0b2eed3cabe548854f824a36411cf7b41c2feb.file.blocksearch-top.tpl.php on line 37, referer: https://svdd.ru/products-comparison

PHP Notice:  Undefined index: ajax_allowed in /var/www/svddru/data/www/svdd.ru/cache/smarty/compile/ed/74/9d/ed749d2af11acf978d4f6deb923e55d40a3b9d12.file.blockcart.tpl.php on line 86, referer: https://svdd.ru/products-comparison

PHP Notice:  Trying to get property of non-object in /var/www/svddru/data/www/svdd.ru/cache/smarty/compile/ed/74/9d/ed749d2af11acf978d4f6deb923e55d40a3b9d12.file.blockcart.tpl.php on line 86, referer: https://svdd.ru/products-comparison

PHP Fatal error:  Cannot use object of type Product as array in /var/www/svddru/data/www/svdd.ru/cache/smarty/compile/ed/74/9d/ed749d2af11acf978d4f6deb923e55d40a3b9d12.file.blockcart.tpl.php on line 121, referer: https://svdd.ru/products-comparison

In console log:

jquery-1.11.0.min.js:169 Uncaught ReferenceError: FancyboxI18nClose is not defined at HTMLDocument.<anonymous> (jquery-1.11.0.min.js:169) at j (jquery-1.11.0.min.js:2) at Object.fireWith [as resolveWith] (jquery-1.11.0.min.js:2) at Function.ready (jquery-1.11.0.min.js:2) at HTMLDocument.K (jquery-1.11.0.min.js:2)

Almost a month I can't understand what's wrong. Thank you in advance for any answer!

Community
  • 1
  • 1
unknown163
  • 57
  • 7

1 Answers1

0

This error is thrown by this function:

public static function packJSinHTML($html_content)
{
    if (strlen($html_content) > 0) {
        $html_content_copy = $html_content;
        if (!preg_match('/'.Media::$pattern_keepinline.'/', $html_content)) {
                $html_content = preg_replace_callback(
                Media::$pattern_js,
                array('Media', 'packJSinHTMLpregCallback'),
                $html_content,
                Media::getBackTrackLimit());

            // If the string is too big preg_replace return an error
            // In this case, we don't compress the content
            if (function_exists('preg_last_error') && preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
                if (_PS_MODE_DEV_) {
                    Tools::error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
                }
                return $html_content_copy;
            }
        }
        return $html_content;
    }
    return false;
}

And the problem seems to be that the content is too big for preg_replace. so you can try to increase pcre.backtrack_limit value to 1000000000.

You could also override this function and comment out these lines:

if (_PS_MODE_DEV_) {
    Tools::error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
}
idnovate
  • 992
  • 1
  • 5
  • 10
  • Changed to 1000000000, still the page of products comparison doesn't work. In console - `jquery-1.11.0.min.js:169 Uncaught ReferenceError: FancyboxI18nClose is not defined at HTMLDocument. (jquery-1.11.0.min.js:169) at j (jquery-1.11.0.min.js:2) at Object.fireWith [as resolveWith] (jquery-1.11.0.min.js:2) at Function.ready (jquery-1.11.0.min.js:2) at HTMLDocument.K (jquery-1.11.0.min.js:2)` – unknown163 Mar 06 '18 at 19:09
  • @АртемГрецков Have you tried to comment the lines that throw the error? – idnovate Mar 07 '18 at 07:54
  • if I comment this line, there isn't this error, still 500 error on page /products-comparison, in logs only this errors: PHP Notice: Undefined index: search_query in .blocksearch-top.tpl.php on line 37, referer: https://svdd.ru/products-comparison PHP Notice: Trying to get property of non-object in …blocksearch-top.tpl.php on line 37, referer: https://svdd.ru/products-comparison – unknown163 Mar 10 '18 at 17:17
  • PHP Notice: Undefined index: ajax_allowed in ..file.blockcart.tpl.php on line 86, referer: https://svdd.ru/products-comparison PHP Notice: Trying to get property of non-object in …file.blockcart.tpl.php on line 86, referer: https://svdd.ru/products-comparison PHP Fatal error: Cannot use object of type Product as array in ….blockcart.tpl.php on line 121, referer: https://svdd.ru/products-comparison – unknown163 Mar 10 '18 at 17:18