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).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3166534-3-dont-use-rules-context-definition.patch | 708 bytes | tr |
Comments
Comment #2
tr commentedThis 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.
Comment #3
tr commentedI 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.
Comment #4
jonathan1055 commentedThe 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:
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?
(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?
Comment #6
tr commentedI 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.
Comment #7
tr commented@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!
Comment #8
jonathan1055 commented@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.
Comment #9
jonathan1055 commentedI have sent a message to @Cyber555 asking about the other modules.
Comment #10
cyber555 commentedHi!
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...
Comment #11
jonathan1055 commentedHi 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?
Comment #12
cyber555 commentedJonathan, 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!
Comment #13
jonathan1055 commentedThank you Cyber555, that's helpful.