Closed (fixed)
Project:
Rules
Version:
8.x-3.x-dev
Component:
Rules Core
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
2 Feb 2019 at 22:24 UTC
Updated:
1 Jan 2020 at 21:24 UTC
Jump to comment: Most recent, Most recent file
Plugins now use the 'context_definitions' key to define their contexts
All Rules Conditions will need to change this in their annotation. All contributed modules that integrate with Rules will also need to change this. Rules core will need to be changed to parse the new 'context_definition' annotation, as well as support the old 'context' annotation.
The @RulesAction annotation definition, which also uses 'context', should also probably be changed to be consistent. That should probably be handled in a separate issue which can be opened when the above is complete.
We have to wait to change this in Rules until core 8.6.x is no longer supported.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 3030295-15-conditions-and-events-context-descriptions.patch | 39.93 KB | tr |
Comments
Comment #2
tr commentedDrupal 8.6.x will be supported until Drupal8.8.0 is released, which is scheduled for December 4, 2019
We can't make this change until Drupal 8.6.x becomes unsupported.
Comment #3
tr commentedWe're a month away from being able to commit this, thus I'm re-opening this so we can work on a patch and get it tested and ready to commit once 8.8.0 is released.
Comment #4
jonathan1055 commentedWould it be possible to change the title either in this issue or #3092085: 'context' deprecated in @Condition annotation because currently they are identical.
Edit: I did not initially see that this issue is for Rules and the other is for Rules Essentials.
Comment #5
tr commentedOK. And I assigned it to myself, since I did most of the work yesterday (still trying to figure out why one of the tests fails). It's a huge patch (>1200 lines) as you might guess, because Context is everywhere in Rules.
Comment #6
jonathan1055 commentedAdding meta parent
Comment #7
tr commentedI will post the patch for this AFTER core 8.8.0 is released - this is a big change and I'd like to get all the little ones that are also waiting committed first so I don't have to be constantly re-rolling this big patch.
Comment #8
tr commentedLet's do this incrementally, like we did with the @RulesAction context. Here is a simpleminded patch which just changes the annotations but doesn't change any other code. I'm posting this to see the extent of the test failures on the testbot.
Note, core 8.7+ has a BC layer for context_definitions so just changing the annotations shouldn't break anything.
Comment #9
tr commentedNow with some code fixes, which SHOULD break something if I missed some changes.
Comment #10
tr commentedComment #11
tr commentedAlthough the tests pass, deprecations are still triggered (as described in the change record). See #3089502-16: [meta] Rules deprecated code and following.
My guess is that these addition "context" keys are coming from our Event plugins, which don't use annotation but rather .yml files for discovery. Thus, I think we need to change the "context" key in our *.rules.events.yml files and Event plugin derivers.
Here is a new patch that combines #10 with changes to the event .yml to change context to context_definitions, and the corresponding changes to the event handling code.
Comment #12
tr commentedAgain.
Comment #13
tr commentedAnd again ...
Comment #14
tr commentedThe patch breaks the autocomplete JavaScript. I will look into this.
Comment #15
tr commentedComment #16
jonathan1055 commentedTested this on Travis , all tests pass and there are no more 'Providing context definitions via the "context" key' deprecation warnings. This is RTBC I think.
Comment #18
tr commentedOK, committed.
Comment #19
jonathan1055 commentedJust to let you know, the recent commits break other contrib modules which are providing Rules Events, RulesActions and Conditions - see #3101377: Argument 2 passed to Drupal\rules\Engine\RulesComponent::addContextDefinition() must implement interface Drupal\rules\Context\ContextDefinitionInterface
This is not a surprise, and I know Rules is allowed to do this as it is only on Alpha release status.
Comment #20
tr commentedYes, those changes will be in the release notes for the next alpha. I also updated all the documentation at the same time I made those commits.
One of the things I use D8 Rules Essentials for is to act as a prototypical Rules ecosystem contributed module, so I have to deal with (and thereby know about) all the side-effects of any core Rules changes.