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

Issue fork rules-3563101

Command icon 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

f2boot created an issue. See original summary.

sujal kshatri made their first commit to this issue’s fork.

skwebdev’s picture

I 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

uberhacker’s picture

@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

ressa’s picture

skwebdev’s picture

@uberhacker Cheers, that fixed it.

_renify_’s picture

StatusFileSize
new845 bytes

I remove the abandoned package.

jan kellermann made their first commit to this issue’s fork.

jan kellermann’s picture

Status: Active » Needs review

Thanks, _renify_ - worked for me, too.

I created a MR (and removed the comment line also).

edvanleeuwen’s picture

Tested and verified.

edvanleeuwen’s picture

Status: Needs review » Reviewed & tested by the community
uberhacker’s picture

Thanks 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!

thomas kaisuka’s picture

Thanks for the patch. Works fine

g_miric’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new671 bytes

Actually we should replace AnnotationRegistry class and use "Drupal\Component\Annotation\Doctrine\AnnotationRegistry"

I'm attaching the patch.

dadderley’s picture

I 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:

ID      Date           Type              Severity   Message
 ------- -------------- ----------------- ---------- -----------------------------------------------------------
  29216   22/Dec 16:30   quiz_subscriber   Warning    Caught 404 exception.
  29215   22/Dec 16:30   page not found    Warning    /app_dev.php/_profiler/open?file=app/config/config.yml
  29214   22/Dec 16:29   php               Error      Error: Class
                                                      "Doctrine\Common\Annotations\AnnotationRegistry" not
                                                      found in
                                                      Drupal\rules\Context\AttributeDiscoveryWithAnnotations->g
                                                      etDefinitions() (line 77 of /home/mysite/domains/z
  29213   22/Dec 16:29   php               Error      Error: Class
                                                      "Doctrine\Common\Annotations\AnnotationRegistry" not
                                                      found in
                                                      Drupal\rules\Context\AttributeDiscoveryWithAnnotations->g
                                                      etDefinitions() (line 77 of /home/mysite/domains/z
  29212   22/Dec 16:28   php               Error      Error: Class
                                                      "Doctrine\Common\Annotations\AnnotationRegistry" not
                                                      found in
                                                      Drupal\rules\Context\AttributeDiscoveryWithAnnotations->g
                                                      etDefinitions() (line 77 of /home/mysite/domains/z
  29211   22/Dec 16:28   php               Error      Error: Class
                                                      "Doctrine\Common\Annotations\AnnotationRegistry" not
                                                      found in
                                                      Drupal\rules\Context\AttributeDiscoveryWithAnnotations->g
                                                      etDefinitions() (line 77 of /home/mysite/domains/z
  29210   22/Dec 16:28   php               Error      Error: Class
                                                      "Doctrine\Common\Annotations\AnnotationRegistry" not
                                                      found in
                                                      Drupal\rules\Context\AttributeDiscoveryWithAnnotations->g
                                                      etDefinitions() (line 77 of /home/mysite/domains/z

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

yousefanbar’s picture

Thanks @g_miric #15 patch worked for me.
Drupal core 10.6.1

dhansen’s picture

Just 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.3

g_miric’s picture

@dhansen Good point.

I'm adding a new patch with core versions update in .info and composer file.

goose2000’s picture

I applied patch #19 after an update to D10.6 - it worked clean - fixed. Thank you.

axle_foley00’s picture

Patch in #19 worked for me as well. Thank you!

jan kellermann’s picture

Adapted patch #19 for MR99.

o'briat’s picture

Works for me, fix the Drupal 11.3 upgrade + no errors so far in the logs
Thanks.

madsciencepro’s picture

Tested #19 and it worked for me.

robbt’s picture

Status: Needs review » Reviewed & tested by the community

I tested this in my development environment and it fixed the error as well. So I think it's safe to mark it RTBC.

ritarshi_chakraborty made their first commit to this issue’s fork.

ritarshi_chakraborty’s picture

I have resolved the errors of the current phpunit version.

fago’s picture

Status: Reviewed & tested by the community » Needs work

Thank 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

smustgrave’s picture

smustgrave’s picture

Priority: Normal » Critical

Think 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

smustgrave’s picture

Status: Needs work » Needs review

Okay tried an approach to cover both. Tests are going to fail for 10 though

matt_zimo’s picture

Is 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.

fago’s picture

Issue summary: View changes

  • fago committed 3e87e265 on 4.0.x authored by smustgrave
    fix: #3563101 Fix >10.6 compatibility issues due to doctrine/annotations...
fago’s picture

Status: Needs review » Fixed

thx! 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.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.