Problem/Motivation
Drupal 10.6 drops doctrine/annotations which is in use by Rules 4.x
See #3550917: doctrine/annotations is abandoned and #3461559: [10.3] Convert RulesAction plugins and discovery to attributes.
Steps to reproduce
Upgrade to Drupal 10.6
Proposed resolution
Follow https://www.drupal.org/node/3551049 and use Drupal\Component\Annotation for Drupal >10.6
While attribute-based annoations are supported since Drupal 10.2, we cannot move over without breaking support for all contrib plugins. See https://www.drupal.org/docs/drupal-apis/plugin-api/attribute-based-plugins
Remaining tasks
I guess
- define alternative of using doctrine/annotations
- add upgrade for existing rules
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3563101-2-rules-replace-annotation-registry.patch | 1.4 KB | g_miric |
| #15 | 3563101-rules-replace-annotation-registry.patch | 671 bytes | g_miric |
| #7 | 3563101-rules-remove-abandoned-package.patch | 845 bytes | _renify_ |
Issue fork rules-3563101
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 #3
skwebdev commentedI just upgraded my dev environment to Drupal 11..3.0 with Rules 4.0.0 installed and I have a site wide WSOD. Apache logs are telling me:
Uncaught PHP Exception Error: "Class "Doctrine\\Common\\Annotations\\AnnotationRegistry" not found" at /var/www/mysite/web/modules/contrib/rules/src/Context/AttributeDiscoveryWithAnnotations.php line 77, referer: http://mysite/admin/reports/dblog
Comment #4
uberhacker commented@skwebdev: I was able to fix this with `composer require doctrine/annotations`. I know it's abandoned but why remove it if causes breakage? SMH
Comment #5
ressaConnecting related issues.
Comment #6
skwebdev commented@uberhacker Cheers, that fixed it.
Comment #7
_renify_ commentedI remove the abandoned package.
Comment #10
jan kellermann commentedThanks, _renify_ - worked for me, too.
I created a MR (and removed the comment line also).
Comment #11
edvanleeuwenTested and verified.
Comment #12
edvanleeuwenComment #13
uberhacker commentedThanks for the patch @_renify_! Definitely worth tagging a new release with this patch applied along with the PHP 8.4 deprecation fixes. The current 4.0.0 "stable" release is broken. Attention maintainers!
Comment #14
thomas kaisuka commentedThanks for the patch. Works fine
Comment #15
g_miric commentedActually we should replace AnnotationRegistry class and use "Drupal\Component\Annotation\Doctrine\AnnotationRegistry"
I'm attaching the patch.
Comment #16
dadderley commentedI ran into this problem while doing a Drupal 11 update.
The first indication of the problem was that I could not access admin/reports page -- WSOD
Drush WS told me this:
I found this issue and tried to apply the patch to the non dev version of the Rules module.
Of course this not work.
So I installed the dev version and applied patch.
Everything seems OK now.
Thanks
Comment #17
yousefanbar commentedThanks @g_miric #15 patch worked for me.
Drupal core 10.6.1
Comment #18
dhansen commentedJust a heads up that if we move ahead by adding the patch at #15 by @g_miric then we also have to update the core version required in rules.info.yml to reflect when the new package was introduced. Something like:
core_version_requirement: ^10.6 || ^11.3Comment #19
g_miric commented@dhansen Good point.
I'm adding a new patch with core versions update in .info and composer file.
Comment #20
goose2000 commentedI applied patch #19 after an update to D10.6 - it worked clean - fixed. Thank you.
Comment #21
axle_foley00 commentedPatch in #19 worked for me as well. Thank you!
Comment #22
jan kellermann commentedAdapted patch #19 for MR99.
Comment #23
o'briatWorks for me, fix the Drupal 11.3 upgrade + no errors so far in the logs
Thanks.
Comment #24
madsciencepro commentedTested #19 and it worked for me.
Comment #25
robbt commentedI tested this in my development environment and it fixed the error as well. So I think it's safe to mark it RTBC.
Comment #27
ritarshi_chakraborty commentedI have resolved the errors of the current phpunit version.
Comment #28
fagoThank you! While the current MR is great, it would mean a BC break and require opening a new branch.
I think we should try to rather avoid this and address the issue by moving over to attributes, since they are supported since Drupal 10.2. See https://www.drupal.org/docs/drupal-apis/plugin-api/attribute-based-plugins
Comment #29
smustgrave commentedOpened #3568059: Remove annotations duplicating attributes
Comment #30
smustgrave commentedThink this counts as critical as this blocks 10.6/11.3
One alternative to keep coverage for both 10.5 and 10.6 would be check the version number and use the full namespace to call the annotation reset.
Can try this evening if no one beats me to it
Comment #32
smustgrave commentedOkay tried an approach to cover both. Tests are going to fail for 10 though
Comment #33
matt_zimo commentedIs this getting fixed? I want to try to create a rule to unpublish nodes by content type based on a date field, but I just get the error when I try to create the condition.
Comment #34
fagoComment #36
fagothx! I discussed the issue with smustgrave on slack, we clarified we need to keep support annotations in order to not break all contrib plugins for now. Thus the last approach to conditonally use the right class based upon drupal version seems the way to go. MR seems good, thus merged! This should fix the issues with Drupal 10.6.