Twig 1.22.0 was released. According to our composer.json definition, you get that automatically when running composer update, which is what you need to do when you are using composer_manager.

Since it seems to contain a possibly unexpected BC break (See http://d8status.md-systems.ch/build.log, tons of "Uncaught PHP Exception LogicException: "Cache can only be a string, false, or a Twig_CacheInterface implementation." at /home/projects/d8modulestatus/internal/vendor/twig/twig/lib/Twig/Environment.php line 269"), we need to update to it and fix that.

Or, if there's a problem with it, at least lock down our version to 1.21.* I guess.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

alexpott’s picture

Title: Update twig to 1.22 » Update PHP dependencies includign Twi
Status: Active » Needs review
FileSize
50.5 KB

Ran composer update twig/twig...

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing twig/twig (v1.21.2)
  - Installing twig/twig (v1.22.0)
    Loading from cache

Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

Was the composer output.

anavarre’s picture

Title: Update PHP dependencies includign Twi » Update PHP dependencies including Twig
dawehner’s picture

Status: Needs review » Needs work

Yeah the BC layer of twig indeed doesn't work as expected.
#2555243: Upgrade path / plan to Twig 2.x aka 2.0 is an issue about updating to twig 2.0

We would need to implement some proper caching:

This is just a start.

<?php

/**
 * @file
 * Contains \Drupal\Core\Template\TwigCache.
 */

namespace Drupal\Core\Template;

class TwigCache implements \Twig_CacheInterface {

  protected $templateCacheFilenamePrefix;

  protected $autoReload;

  public function __construct($template_cache_filename_prefix) {
    $this->templateCacheFilenamePrefix = $template_cache_filename_prefix;
  }

  /**
   * {@inheritdoc}
   */
  public function generateKey($name, $className) {
    // We override the cache filename in order to avoid issues with not using
    // shared filesystems. The Twig templates for example rely on available Twig
    // extensions, so we use the twig extension hash which varies by extensions
    // and their mtime.
    // @see \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass

    // The first part is what is invalidated.
    return $this->templateCacheFilenamePrefix . '_' . basename($name) . '_' . $className;
  }

  /**
   * {@inheritdoc}
   */
  public function has($key) {
  }

  /**
   * {@inheritdoc}
   */
  public function write($key, $content) {
  }

  /**
   * {@inheritdoc}
   */
  public function load($key) {
    $cls = $this->getTemplateClass($name);

    if (isset($this->loadedTemplates[$cls])) {
      return $this->loadedTemplates[$cls];
    }

    if (!class_exists($cls, FALSE)) {
      $cache_filename = $this->generateKey($name, $cls);

      if ($cache_filename !== FALSE) {
        // If autoreload is on, check that the template has not been
        // modified since the last compilation.
        if ($this->isAutoReload() && !$this->isFresh($cache_filename, $name)) {
          $this->updateCompiledTemplate($cache_filename, $name);
        }

        if (!$this->storage()->load($cache_filename)) {
          $this->updateCompiledTemplate($cache_filename, $name);
          $this->storage()->load($cache_filename);
        }
      }
      if (!class_exists($cls, FALSE)) {
        $compiled_source = $this->compileSource($this->loader->getSource($name), $name);
        eval('?' . '>' . $compiled_source);
      }
    }

    if (!$this->runtimeInitialized) {
      $this->initRuntime();
    }

    return $this->loadedTemplates[$cls] = new $cls($this);
  }

  /**
   * {@inheritdoc}
   */
  public function getTimestamp($key) {
  }

}

The last submitted patch, 2: 2568085-2.patch, failed testing.

dawehner’s picture

Assigned: Unassigned » dawehner

I'll try to work on that for a while.

The last submitted patch, 2: 2568085-2.patch, failed testing.

dawehner’s picture

Assigned: dawehner » plach
Status: Needs work » Needs review

Posted my result on [#25552433-35]

For now we should just limit our dependencies.

star-szr’s picture

I created #2568171: Upgrade to Twig 1.22 and implement our own cache class to upgrade to Twig 1.22.0 and add our own cache class.

plach’s picture

Assigned: plach » Unassigned
FileSize
897 bytes
plach’s picture

Issue tags: +D8 Accelerate
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

+1 for now!

plach’s picture

Title: Update PHP dependencies including Twig » Lock Twig on ~1.21.2 until we are able to upgrade to 1.22.0
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 9343f6c on 8.0.x
    Issue #2568085 by plach, alexpott, dawehner, Berdir: Lock Twig on ~1.21....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.