Drupal 10 compatibility fix

Created on 9 October 2023, about 1 year ago

Problem/Motivation

Getting an error on drush cr after upgraded to Drupal 10.

Steps to reproduce

Upgrade to Drupal 10
type: drush cr

www-data@8e3866cce05e:/app$ drush cr

Fatal error: Uncaught Error: Class "Twig_Extension" not found in /app/web/modules/contrib/daterange_simplify/src/TwigExtension/Extension.php:14
Stack trace:
#0 /app/vendor/composer/ClassLoader.php(582): include()
#1 /app/vendor/composer/ClassLoader.php(433): Composer\Autoload\{closure}('/app/web/module...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\daterang...')
#3 /app/web/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php(183): is_subclass_of('Drupal\\daterang...', 'Twig\\Extension\\...')
#4 /app/web/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php(118): Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass->processServiceCollectorPass(Array, 'twig', Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#5 /app/vendor/symfony/dependency-injection/Compiler/Compiler.php(80): Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#6 /app/vendor/symfony/dependency-injection/ContainerBuilder.php(767): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#7 /app/web/core/lib/Drupal/Core/DrupalKernel.php(1335): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#8 /app/web/core/lib/Drupal/Core/DrupalKernel.php(934): Drupal\Core\DrupalKernel->compileContainer()
#9 /app/web/core/lib/Drupal/Core/DrupalKernel.php(494): Drupal\Core\DrupalKernel->initializeContainer()
#10 /app/web/core/includes/utility.inc(34): Drupal\Core\DrupalKernel->boot()
#11 /app/vendor/drush/drush/src/Commands/core/CacheCommands.php(228): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#12 [internal function]: Drush\Commands\core\CacheCommands->rebuild(Array)
#13 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
#14 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#15 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#16 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#17 /app/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /app/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /app/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /app/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /app/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /app/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /app/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run(Array)
#24 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
#25 {main}
thrown in /app/web/modules/contrib/daterange_simplify/src/TwigExtension/Extension.php on line 14
[warning] Drush command terminated abnormally.
www-data@8e3866cce05e:/app$

Proposed resolution

small update on daterange_simplify/src/TwigExtension/Extension.php for Drupal 10.

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024