Problem/Motivation

In the file "typed_data.info.yml" there is not the record about the rules dependency.
But Drupal\rules\Context\ContextDefinition is used in the code:

typed_data/src/Plugin/TypedDataFormWidget/SelectWidget.php

Steps to reproduce

I tried to remove the rules module and saw that after rules directory removing the site was dying for no apparent reason.
Message was:

Fatal error: require(): Failed opening required '.../modules/contrib/rules/src/Context/ContextDefinition.php' (include_path='...') in .../vendor/symfony/class-loader/ApcClassLoader.php on line 112

It was very strange, because I removed rules module by the common way without any warnings.

So I searched /rules/ required in the "contrib" directory and found lines "\rules\" in the typed_data module (and more lines in another module).

Comments

Cyber555 created an issue. See original summary.

tr’s picture

This module is not supposed to be dependent upon Rules. That line of code has been there for three years and you're the first one to notice it - I'll look into this over the weekend.

tr’s picture

Version: 8.x-1.0-alpha5 » 8.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new708 bytes

I think this is all that needs to be done. It seems that was left over from when the typed data code was moved out of the Rules module.

jonathan1055’s picture

Title: In module dependencies there is not "rules" module » Remove accidental use of rules\Context\ContextDefinition

The patch looks fine, but just a few things to note:

(a) I could not reproduce the error in the first place. The steps I tried were:

  1. Install clean D8.9
  2. Install Rules, Typed Data and Typed Data Widgets
  3. Import a rule and trigger it, to make sure Rules is working
  4. Uninstall Rules and clear cache
  5. Delete the /rules/ directory

I don't get your fatal error and I can still use the Typed Data widgets examples, and various other things on the site. @Cyber555 What were the exact steps that you used to cause this error?

and found lines "\rules\" in the typed_data module (and more lines in another module)

(b) What other contrib modules did you find /rules/ in? Do we need to check them too, or did they have proper dependency on Rules?

(c) If that use statement is actually needed then it implies we are missing some test coverage, because Rules is not loaded during Typed Data tests. Should we investigate the missing test coverage first? Or you could commit this patch, then investigate later?

  • TR committed 968ef6a on 8.x-1.x
    Issue #3166534 by TR: Remove accidental use of rules\Context\...
tr’s picture

Status: Needs review » Fixed

I can't reproduce the problem either, but the use of the Rules class is clearly wrong. This and #3168398: Don't use Doctrine directly seem to indicate that this typed_data Context code is not being used at all - otherwise we should have seen errors - but investigating that is a matter for another issue.

Committed.

tr’s picture

@Cyber555: It would still be very helpful if you could answer the questions in #4 - if there are other affected modules we should fix those too!

jonathan1055’s picture

@Cyber555 I echo TR's request. Please see my questions in #4. It would be really helpful if you could let us know what other modules you found the accidental use of Rules code. Thanks very much.

jonathan1055’s picture

I have sent a message to @Cyber555 asking about the other modules.

cyber555’s picture

Hi!
Sorry for my silence, I don't get any notes about messages in my email, so I wasn't aware of this discussion.
Another module, that want Rules module is entityqueue (rather its RulesAction plugin).
https://www.drupal.org/project/entityqueue/issues/3166532
The creator said that it is not a mistake that my site is dying when I remove rules-module from its sources...

jonathan1055’s picture

Hi Cyber555,
Thanks for the reply. You can set you default notificatoins via https://www.drupal.org/user/nnn/project-issue

Useful to see #3166532: Module dependencies don't have "rules" - does that imply that you managed to remove the Rules module but that some Rules configuration did not get deleted?

cyber555’s picture

Jonathan, the Entityqueue module has some plugins that use Rules module classes. I didn't enable them during installation, I think it was automatically. So, when I'm deleting the Rules module, I got error messages and a dead website. I think it is a wrong way to use dependencies without warning the system, but Entityqueue module creator thinks else.
I don't think the Rules module can find any third-party plugins all over the website to warn me about deleting problems. It was not Rules configurations, it was plugins of the Entityqueue module!

jonathan1055’s picture

Thank you Cyber555, that's helpful.

Status: Fixed » Closed (fixed)

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