Problem/Motivation
The doctrine/annotations package has been marked a abandoned: https://github.com/doctrine/annotations/commit/a64d7f063e1602bbbc8e70a07...
Since #3252386: Use PHP attributes instead of doctrine annotations we support native attributes but drupal/core still depends on doctrine/annotations.
Steps to reproduce
Run composer install, you get this warning:
Package doctrine/annotations is abandoned, you should avoid using it. No replacement was suggested.
Proposed resolution
Convert every remaining annotation to attributes and remove doctrine/annotations from dependencies.
Copy the code that we use into a core namespace and remove doctrine/annotations from dependencies.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
The doctrine/annotations package is marked abandoned upstream. Parts of the code have been forked into Drupal core. This change only affects custom code that was handling PHP annotations; for more information, see the change record.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3550917-16.patch | 58.08 KB | johnatas |
Issue fork drupal-3550917
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
prudloff commentedComment #3
catchWe deprecated annotations already, but for removal in Drupal 13. https://www.drupal.org/node/3522776
The only remaining annotations usages in Drupal 11 are in some migrate plugins (which are going to be removed in Drupal 12) and the bc layer for annotations.
For Drupal 11, I think our only option is to fork Doctrine Annotations and un-abandon it to suppress the warning, we've had to fork entire dependencies before (for the Zend/Laminas change iirc).
For Drupal 12, we have #3400121: Allow opt-out of annotation parsing to make annotation discovery opt-out, we could also make it opt-in or bring forward the Drupal 13 removal to Drupal 12, although that would need an announcement and it would need to be announced quickly.
As @berdir pointed out in that issue the security surface is minimal, the main issue is support for newer PHP versions, which could get worse the further into Drupal 12's release cycle we are.
Comment #4
catchMoving this to critical, while we will end up with the same code running or not running, it would be good to resolve this asap especially since this is likely to lead to lots of duplicate reports.
Comment #5
longwaveWe forked parts of Doctrine already by copying them into core namespaces, so I think the simplest solution is to do that for the remaining classes that we use.
Comment #6
ghost of drupal pastAs the author of some of that code: you could also delete some code after forking, after all Drupal only ever supported class annotations in proper PSR namespaces.
Comment #8
longwaveCopied all the classes that we use into core; DocParserTest still passes locally, let's see if anything else is broken. Unsure if we should copy any other tests from Doctrine.
Comment #9
longwaveOnce again I am surprised that this is green so easily.
Comment #10
yesct commentedI can draft a change record. (https://www.drupal.org/community/contributor-guide/task/write-a-change-r... )
Draft: https://www.drupal.org/node/3551049
Comment #11
quietone commentedSomething is amiss, the link for the CR in #10 is a 404 for me. I searched the change records as well and didn't find one for this.
Comment #12
longwaveLet's try to add some backward compatibility via
moved_classesand/orclass_alias().Comment #13
godotislateThis is a 403 for me. And I don't see a link the CR in the sidebar here.
Comment #14
berdirYesCT might have administer node permission or something on d.o and mixed up the draft and published checkboxes, has happened before as. Someone else with enough permissions should able to publish it while keep it a draft?
Comment #15
longwavePublished the change record node (but not the change record itself)
Comment #16
johnatas commentedHello,
Thank you very much for the work.
For those who might be interested, I’m attaching a patch that includes the current changes from the MR !13433 (core directory only).
Comment #17
berdirYou can't patch composer dependencies, there is no point in using (or uploading) patch files here. Nothing is broken, nothing is insecure, this is just critical exactly because a lot of people are going to be asking questions about this and we want it resolved quickly. Ignore the warning and stay tuned.
Comment #18
loopy1492 commentedRight now we are auditing composer to fail on abandoned packages. Is the Drupal security team's assessment that it is safe to skip this error on our validation/audit steps in CI?
Comment #19
longwaveAdded a BC layer for AnnotationException, and updated the change record.
I am not sure we should provide BC for anything else here. If you were depending on doctrine/annotations, and you required it in composer.json: your code will still work. If you were depending on doctrine/annotations as a transitive dependency of core, I am not sure that is core's responsibility to fix.
Comment #20
godotislateI compared the
Drupal\Component\Annotation\Doctrine\*classes and toDoctrine\Tests\Common\Annotations\*2.0.2 classes and confirmed that the code is essentially identical.BC for exception looks good. Also, if this is backported to D10, I think the CR alone is enough without any BC.
LGTM.
Comment #21
xjmComment #22
xjmComment #23
xjmComment #24
xjmDiscussed with @catch and we would like to backport this to 10.6 as well.
Comment #25
longwaveComment #26
yesct commentedFYI, I saw Audit: add option to ignore individually abandoned packages #12572 https://github.com/composer/composer/pull/12572 was just merged.
Comment #27
catchThis looks good but it needs a rebase.
Comment #28
longwaveRebased, back to RTBC.
Comment #31
catchCommitted/pushed to 11.x and cherry-picked to 11.3.x, thanks!
Moving to 10.6.x for backport.
Comment #33
godotislatedoctrine/annotations is still in the composer.lock, which is causing test failures on HEAD #3554820: HEAD testing is broken.
Comment #36
catchCommitted the follow-up, PHPStan is happy in the latest branch job now.
Comment #37
godotislate10.6.x is locked to doctrine/annotations 1.14.4, so should the Drupal forked classes in 10.6.x be copies of that version instead of 2.0.2?
Comment #38
mondrakeI think this should be cherrypicked to 11.3.x too
Comment #39
longwave@godotislate not too sure it matters given we are changing the namespaces anyway, can't remember what the break was between annotations 1 and 2. Also not sure what to do about the exception BC layer though as that isn't supported in the same way in D10.
Comment #41
godotislateAttempted a backport to 10.6 on MR 13610 using doctrine/annotations 1.14.4, but ran into some phpstan issues. Will have to loop back later to investigate.
Comment #42
catchI thought I'd cherry-picked to 11.3.x but apparently not, done now.
Comment #43
godotislateFixed the PHPStan issues, but tests are failing on the 10.6 MR.
Comment #44
godotislatehttps://git.drupalcode.org/project/drupal/-/merge_requests/13610#note_61... for 10.6 is ready.
@catch re: #42 I think the 11.3.x commit might not have been pushed. Maybe it happened during the Gitlab maintenance period?
Comment #47
quietone commented@godotislate, thanks for making the 10.6 MR
Comment #48
godotislateIs the 10.6 MR good to go to RTBC?
Comment #49
longwave10.6 MR looks good to me. We could
class_alias()the exception if we think it's worth it, but unsure if that comes with any risks ifdoctrine/annotationsis still installed for some reason.Comment #50
eduardo morales albertiHi, why is this merge into branch 11.x, but is not on the latest releases? like 11.2.8 https://git.drupalcode.org/project/drupal/-/blob/11.2.8/composer.lock?re...
Composer audit flags the package doctrine as deprecated, which is a security issue, and it has the value critical.
Is there any planned release with this change?
Comment #51
longwaveA deprecated package is not a security issue; it is a warning that the package will become unsupported in the future. We have deliberately not made this change in 11.2 because there is a chance it will break existing sites and we try to avoid that as much as possible in patch releases. It will be released with 11.3.0 in December.
Comment #54
catchCommitted/pushed to 10.6.x, thanks!
Comment #56
eduardo morales albertiThank you for the explanation @longwave
Comment #57
longwavePublished the change record.
Comment #58
longwaveComment #59
yesct commentedIn case folks are waiting for the releases,
and to follow-up on my previous comment https://www.drupal.org/project/drupal/issues/3550917#comment-16323381
If folks' CI was blocking them, I wanted to share that people can add to composer.json
But I also want to note that, I recommend also adding a followup issue to some internal tracker (not d.o) to also remove that workaround once the d.o core releases come out. Which by looking at https://www.drupal.org/about/core/policies/core-release-cycles/schedule#... I'm guessing will be "Week of December 8, 2025 (UTC)"