daco65 Posted June 9 Share Posted June 9 Buongiorno a tutti, ho un problema con il file error.log, raggiunge grosse dimensioni in breve tempo a causa di questo errore che si ripete innumerevoli volte: PHP Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/svitllgj/public_html/var/cache/prod/smarty/compile/themecarlayouts_layout_left_column_tpl/9e/88/d1/9e88d15416b0c9d6392ff6615eb204b63e6ed6f4_2.file.product.tpl.php on line 291 Come posso risolvere il problema? Ringrazio anticipatamente. Link to comment Share on other sites More sharing options...
El Patron Posted June 10 Share Posted June 10 howdy, maybe this solves, make sure to test this on a test copy of your shop (best practice) before making production changes. 1. Locate the problematic variable Open your theme’s templates/catalog/product.tpl (or your override) and search for the call to htmlspecialchars() around where the warning points (line 291 of the compiled file). This tells you which {$…} variable is being passed in as an array instead of a string. 2. Convert the array to a string in the template Wrap the variable in a test/implode so only strings reach htmlspecialchars(). For example, replace: {$myVar} with: {if is_array($myVar)} {$myVar|@implode:', '} {else} {$myVar} {/if} —or— if you only need the first element: {$myVar[0]|default:''} alternate solutions: 3. Or fix it at assignment time in PHP If you prefer to handle it in your module or controller, do: $value = is_array($rawValue) ? implode(', ', $rawValue) : $rawValue; $this->context->smarty->assign('myVar', $value); 4. Override, don’t edit core or cache files Copy product.tpl to /themes/your_theme/templates/catalog/product.tpl, make your changes there, then clear the cache. Never edit var/cache or PrestaShop core files directly. to finish up: 5. Clear Smarty cache & recompile Delete /var/cache/prod/* (and /dev/* if used). PrestaShop will rebuild your templates without the old warning. 6. Verify the fix Reload a product page and monitor error.log. The “array given” warning should be gone and your log file will stop growing uncontrollably. 1 Link to comment Share on other sites More sharing options...
El Patron Posted June 11 Share Posted June 11 On 6/9/2025 at 6:33 AM, daco65 said: Buongiorno a tutti, ho un problema con il file error.log, raggiunge grosse dimensioni in breve tempo a causa di questo errore che si ripete innumerevoli volte: PHP Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/svitllgj/public_html/var/cache/prod/smarty/compile/themecarlayouts_layout_left_column_tpl/9e/88/d1/9e88d15416b0c9d6392ff6615eb204b63e6ed6f4_2.file.product.tpl.php on line 291 Come posso risolvere il problema? Ringrazio anticipatamente. @daco65 I forgot to mention easy solution, for line approx 291 suppress the php warning, prefix the php statement with a @, see below for example. // Without suppression, fopen will emit a warning if the file doesn't exist $handle = fopen('nonexistent.txt', 'r'); // Suppressed: no warning is emitted, but $handle will be FALSE on failure $handle = @fopen('nonexistent.txt', 'r'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now