Class "Doctrine\Deprecations\Deprecation" not found

Created on 9 December 2024, 9 days ago

Hello and thanks for all the efforts,

Problem/Motivation

After updating to 10.4.0-rc1, I've started receiving the error message below:

Error: Class "Doctrine\Deprecations\Deprecation" not found in Doctrine\Common\Lexer\Token->offsetGet() (line 104 of /var/www/html/vendor/doctrine/lexer/src/Token.php)

Steps to reproduce

My PHP version is 8.3.14
Output of the composer depends doctrine/deprecations command is below:

doctrine/collections    2.2.2      requires doctrine/deprecations (^1)     
doctrine/lexer          2.1.1      requires doctrine/deprecations (^1.0)   
drupal/core-recommended 10.4.0-rc1 requires doctrine/deprecations (~1.1.3)

I've also tried deleting "vendor" directory and re-run the composer install command, but it didn't work.

What should I do?

Best,
Orkut

🐛 Bug report
Status

Active

Version

10.4

Component

composer

Created by

🇹🇷Turkey orkut murat yılmaz Istanbul

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

Comments & Activities

  • Issue created by @orkut murat yılmaz
  • 🇩🇪Germany alxn

    I received similar warnings with drupal/core 10.3.10 and doctrine/deprecations 1.1.4 when visiting pages under /admin:

    Warning: include(): Failed opening '/var/www/html/vendor/composer/../doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php' for inclusion (include_path='/var/www/html/vendor/pear/archive_tar:/var/www/html/vendor/pear/console_getopt:/var/www/html/vendor/pear/pear-core-minimal/src:/var/www/html/vendor/pear/pear_exception:.:/usr/local/lib/php') in include() (Line 576 in /var/www/html/vendor/composer/ClassLoader.php)
    
    #0 /var/www/html/docroot/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
    #1 /var/www/html/vendor/composer/ClassLoader.php(576): _drupal_error_handler()
    #2 /var/www/html/vendor/composer/ClassLoader.php(576): include('...')
    #3 /var/www/html/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
    #4 /var/www/html/vendor/doctrine/lexer/src/Token.php(104): Composer\Autoload\ClassLoader->loadClass()
    #5 /var/www/html/docroot/core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php(619): Doctrine\Common\Lexer\Token->offsetGet()
    ...

    Warnings went away after downgrading to doctrine/deprecations 1.1.3.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    When check the browser, I see the WSOD, with the full error message below:

    The website encountered an unexpected error. Try again later.
    Error: Class "Doctrine\Deprecations\Deprecation" not found in Doctrine\Common\Lexer\Token->offsetGet() (line 104 of /var/www/html/vendor/doctrine/lexer/src/Token.php).
    
    Doctrine\Common\Lexer\Token->offsetGet() (Line: 619)
    Drupal\Component\Annotation\Doctrine\DocParser->Annotations() (Line: 338)
    Drupal\Component\Annotation\Doctrine\DocParser->parse() (Line: 101)
    Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader->getClassAnnotations() (Line: 125)
    Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader->getClassAnnotation() (Line: 145)
    Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery->getDefinitions() (Line: 119)
    Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 213)
    Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
    Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 135)
    Drupal\Core\Entity\EntityTypeManager->getDefinition() (Line: 260)
    Drupal\Core\Entity\EntityTypeManager->getHandler() (Line: 195)
    Drupal\Core\Entity\EntityTypeManager->getStorage() (Line: 42)
    Drupal\eca\Token\CurrentUserDataProvider->__construct() (Line: 261)
    Drupal\Component\DependencyInjection\Container->createService() (Line: 179)
    Drupal\Component\DependencyInjection\Container->get() (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 275)
    Drupal\Component\DependencyInjection\Container->createService() (Line: 179)
    Drupal\Component\DependencyInjection\Container->get() (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService() (Line: 179)
    Drupal\Component\DependencyInjection\Container->get() (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService() (Line: 179)
    Drupal\Component\DependencyInjection\Container->get() (Line: 105)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 239)
    Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (Line: 91)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    When I updated my core with drupal 10.4.x-dev, I start reaching to my web interface and all the errors become warnings. After rebuilding the cache, warnings disappear, as told on comment #2.

  • 🇬🇧United Kingdom joachim

    I got this on Drupal 10.3.x, when I upgraded drupal/csv_serialization from 4.0.0 => 4.0.1.

    The problem appears to be doctrine/deprecations 1.1.4. I forced a downgrade of that to the previous version I had -- 1.1.3 -- and with no other package changes, the error stopped.

    Should this not be major or critical?

  • 🇫🇷France guilhom Toulouse

    I can confirm that I also updated some modules few minutes ago and received the same error with WSOD on multiple pages.

    It appears indeed that doctrine/deprecations 1.1.4 is the problem.
    Downgrading to 1.1.3 error disappears.

  • 🇬🇧United Kingdom joachim

    The problem is that the class has been moved:

    > lib/Doctrine/Deprecations/Deprecation.php → src/Deprecation.php

    I don't know why autoload hasn't caught up.

  • 🇫🇷France guilhom Toulouse

    Running composer dump-autoload -o seems to help.
    From what I see on doctrine/deprecations, they moved source location from lib/ to src/

  • 🇩🇪Germany alxn

    I could now reproduce the WSOD error with Drupal 10.3.10 and doctrine/deprecations 1.1.4, it was shown after clearing the cache and editing a field of a content type. The error went away with doctrine/deprecations 1.1.3.

  • 🇫🇷France dcoppel

    After upgrade doctrine/deprecations from 1.1.3 to 1.1.4 my drupal site crash with this error : Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: "The "broken" plugin does not exist. Valid plugin IDs for Drupal\\views\\Plugin\\ViewsHandlerManager are: datetime, groupby_numeric, date, random" at myrootsite/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 53

  • 🇻🇳Vietnam datati

    I have the same problem when upgrading doctrine/deprecations:1.1.3 to 1.1.4. I have to downgrade it. The site is back. Waiting for the problem to be fixed.

    composer require doctrine/deprecations:1.1.3

  • 🇬🇧United Kingdom joachim

    @andypost I got this error on 10.3

  • 🇺🇸United States sissi.schulmeister

    After upgrading the Diff module from 8.x-1.7 to 8.x-1.8 on a Drupal 10.3.x site, I am getting a WSOD and the same error as mentioned: Error: Class "Doctrine\Deprecations\Deprecation" not found in Doctrine\Common\Lexer\Token->offsetGet() (line 104 of /var/www/vendor/doctrine/lexer/src/Token.php).

  • 🇺🇸United States josh.fabean

    I also am getting this trying to upgrade to 10.3.10, for me downgrading doctrine/deprecations:1.1.3 isn't working.

  • I'm also getting this issue,
    For me was after updating the taxonomy manager module.
    As the original post, stated also deleted the "vendor" directory and re-run the composer install command, but it didn't work.

    My only way to get out of this issue was to reimport the database from previous backup.

  • 🇧🇪Belgium shaesen Mechelen

    Same issue here on multiple sites today after running 'composer update' for Gin Theme and Gin Toolbar.

    Downgrade of doctrine/depreciations to 1.1.3 solves the issue

  • 🇬🇧United Kingdom longwave UK

    As per this GitHub comment it's likely that if you are suffering from this after updating then you need to also clear your APCu cache - the easiest way to do this is to restart your webserver or PHP-FPM.

  • 🇳🇿New Zealand quietone

    Restore the standard issue template and updated the proposed resolution to direct to #19.

  • 🇬🇧United Kingdom fonant

    Re-starting php-fpm fixed the problem for me - thanks for the tip @longwave!

  • 🇬🇧United Kingdom longwave UK

    Thanks for confirming, marking this fixed as I believe that is the solutionm for all affected sites - there is nothing we can do in Drupal core to help with this.

  • 🇺🇸United States aryosys

    Re-starting php-fpm fixed the problem for me - thanks for the tip @longwave!

  • Thanks, Guilhom! Option #9 worked perfectly for me.

  • 🇫🇷France eddylbs Paris

    Hello,

    Downgrade of doctrine/depreciations to 1.1.3 in #14 works for me.

    Thanks.

  • I don't agree that this isn't a breaking change, because it is in fact in some cases. For Drupal sites on shared hosting, a bugfix release like 1.1.4 may require opening a support ticket with the hosting company to have a restart. And yes, I understand that mitigations on the library maintainer's side are not easy. They are not even practical in many cases.

    Drupal's PHP requirements say nothing about needing to restart the PHP process during deployments. I asked at #3153335: Document $settings['deployment_identifier'] (and that it fixes moved class autoloader caching) if that documentation would be sufficient in a case like this. If it isn't we need to update the PHP requirements accordingly.

  • I've got this after installing the feeds module: composer require 'drupal/feeds:^3.0@RC'.

    Running composer dump-autoload -o as suggested by @guilhom worked for me! Thanks @guilhom!

  • 🇨🇱Chile so4

    Thanks, Toulouse! #9 works perfectly.

  • 🇬🇧United Kingdom joachim

    Should we update our requirements to say that the PHP file cache should be clearer whenever modules or Composer packages are updated?

    This could happen again any time that a package decides to move a class.

    It could also happen if a package uses 3rd-party attributes -- see Allow attribute-based plugins to discover supplemental attributes from other modules Active .

  • Probably. And then there is the auto-updates feature to consider.

  • 🇪🇨Ecuador andres.torres

    Just ran a composer update --with-dependencies on a Drupal 10.3.10 site and found the issue described here but as stated on comment #19 just needed to restart the apache and php-fpm services and site went back to normal, no need to downgrade Doctrine.

  • 🇦🇹Austria nofue

    Merci guilhom, #9 is the solution: composer dump-autoload -o

  • 🇨🇭Switzerland handkerchief

    In my case it was the installation of the Webform libraries: https://www.drupal.org/node/3003140
    ... which caused the error

    #19 composer dump-autoload -o was also the solution. Hope there is no downside to this.

  • 🇺🇸United States greatmatter

    Thank you @guilhom - composer dump-autoload -o did the trick.

  • 🇮🇳India ashwinsh Pune

    https://www.drupal.org/project/drupal/issues/3492523#comment-15892853 🐛 Class "Doctrine\Deprecations\Deprecation" not found Active is working for me

Production build 0.71.5 2024