"PHP Fatal error: Cannot redeclare twig_cycle()" occurs when upgrading Drupal 10 after May 2024

Created on 23 May 2024, about 1 month ago
Updated 24 June 2024, 4 days ago

Problem/Motivation

I just would like to share this issue with the module users. Actually not a bug report of the module, so no action required for it.
After I upgraded Drupal from 10.2.3 to 10.2.6 this May, WSOD (HTTP 500 error) occurred.
- simpleSAMLphp Authentication: 4.0.0
- SimpleSAMLphp: 2.1.3
- PHP: 8.3.3

Apache httpd log was;
[Fri May 17 07:57:13.553680 2024] [php:error] [pid 2148:tid 139920974804544] [client 10.228.107.156:39984] PHP Fatal error: Cannot redeclare twig_cycle() (previously declared in /var/www/html/drupal/vendor/twig/twig/src/Resources/core.php:20) in /var/simplesamlphp-2.1.3/vendor/twig/twig/src/Extension/CoreExtension.php on line 334

Steps to reproduce

1. Upgrade Drupal from 10.2.3 to 10.2.6.
2. Login at the Drupal login screen.
3. WSOD occurs with Firefox, HTTP 500 Error message appears with Chrome.

Cause

Conflict between twig under /drupal/vendor/twig/twig (3.10.3) and twig under /simplesamlphp/vendor/twig/twig (3.8.0).
Maybe some change in twig 3.9 is affecting. (https://github.com/twigphp/Twig/blob/3.x/CHANGELOG)

Resolution

You also upgrade SimpleSAMLphp to 2.2.2 (or later) when you upgrade Drupal 10 after May 2024. Then twig under /simplesamlphp/vendor/twig/twig will be updated to 3.9.3 (or later).

🐛 Bug report
Status

Closed: won't fix

Version

4.0

Component

Miscellaneous

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kubokura
  • 🇮🇳India muthukris

    Hello kubokura,

    Facing the same issue after the Drupal upgrade from 9.5.11 to 10.2.6.

    My application's actual SimpleSAMLphp and PHP Versions are,
    - simpleSAMLphp Authentication: 4.0.0
    - SimpleSAMLphp: 2.1.6
    - PHP: 8.1.28

    Upgraded the SimpleSAMLphp version from 2.1.6 to 2.2.2 after looking into your post. But still, I ended up with the same issue.

    Chrom Browser: HTTP ERROR 500

    PHP Fatal error: Cannot redeclare twig_cycle() (previously declared in docroot/vendor/twig/twig/src/Extension/CoreExtension.php:328) in simplesamlphp/vendor/twig/twig/src/Resources/core.php on line 23

  • Hello muthukris, you might want to check each Twig version.
    head [your path]/docroot/vendor/twig/twig/CHANGELOG -n 1
    head [your path]/simplesamlphp/vendor/twig/twig/CHANGELOG -n 1

    In my case;
    drupal
    # 3.10.3 (2024-05-16)
    simplesamlphp 2.2.2
    # 3.9.3 (2024-04-18)

    If Twig version under your docroot/vendor/twig/twig is before 3.9 and you are using composer for upgrading Drupal, how about trying Drupal 10.2.7 dry-run check? For example;
    cp -p composer.json composer.json.`date '+%Y%m%d'`
    cp -p composer.lock composer.lock.`date '+%Y%m%d'`
    composer require drupal/core:10.2.7 drupal/core-composer-scaffold:10.2.7 drupal/core-project-message:10.2.7 --update-with-dependencies --no-update
    composer update drupal/core "drupal/core-*" --with-all-dependencies --dry-run

    I think you can see Twig version to be update. (After confirmation, please revert composer.json and composer.lock.)

  • Status changed to Closed: won't fix 4 days ago
  • One month has passed, this could be closed as won't fix.

Production build 0.69.0 2024