php 7.4 twig for opencart

How to fix TWIG whitespace bug in Php 7.4 and Opencart 3.0.x

If you recently upgraded to php 7.4 and are using Opencart 3.0.x.x, you may encounter some bugs. In the following description I will show you how to repair them. If you login to the admin page  and Display errors option is Enabled, then on your screen you will see more messages with this error:

Notice: Trying to access array offset on value of type null in /storage/vendor/scss.inc.php on line 1753

To fix this error/warning you need to go to your storage/vendor and edit scss.inc.php and change this code:

$key = $key[1];

in to:

$key = isset($key[1]) ? $key[1] : null;

Or to set Display errors to Off.

To fix this design bug you need to navigate to system/library/template/twig/ and edit the file Lexer.php. Here you need to change this code(lines 163-165 ):

$text = rtrim($text);

with this code

  if ($this->options['whitespace_trim'] === $this->positions[2][$this->position][0]) {
                // whitespace_trim detected ({%-, {{- or {#-)
                $text = rtrim($text);
            }

After that whitespace will work again and icons will be shown.

Disabling “Use Socket For PHP-FPM” did the trick.


Leave a Reply