Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 313863

TwigEnvironment $loader argument cannot be NULL

$
0
0

Problem/Motivation

The signature of TwigEnvironment::__construct() is:

  public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, LoaderInterface $loader = NULL, array $options = []) {

However, passing NULL as $loader results in a fatal error:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Twig\Environment::setLoader() must implement interface Twig\Loader\LoaderInterface, null given, called in core/lib/Drupal/Core/Template/TwigEnvironment.php on line 98 and defined in vendor/twig/twig/src/Environment.php:604

This is because

    $this->setLoader($loader);

and the setLoader() signature is

    public function setLoader(LoaderInterface $loader)

Steps to reproduce

Proposed resolution

Remove the NULL default argument.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 313863

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>