Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When exporting context configuration with Blocks reactions, not all dependencies are added.
Proposed resolution
Process the Blocks collection and add instances dependencies.
Remaining tasks
Work on a solution- Review
- Add tests? (The project doesn't seem to have test coverage)
- Commit
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope, but on exporting the generated config will have the dependencies property filled in.
Comment | File | Size | Author |
---|---|---|---|
#21 | 2926843-21.patch | 3.2 KB | paulocs |
#21 | interdiff-20-21.txt | 663 bytes | paulocs |
#20 | 2926843-19.patch | 3.2 KB | paulocs |
#19 | 2926843-19.patch | 1.09 KB | manish-31 |
#9 | 2926843-9.patch | 1.2 KB | gambry |
Comments
Comment #2
Joao Sausen CreditAttribution: Joao Sausen at Dexa commentedFor now the only content I can think of that can be added is block_content.
Comment #3
maaty388 CreditAttribution: maaty388 commentedReplace the line 388 with this
Just one depency injection...
I tested this.
Also where can I see if depencies are getting exported?
I went debugging and saw that something is added to dependency array.
Comment #4
Joao Sausen CreditAttribution: Joao Sausen at Dexa commentedJust export and the the yml file generated, you will be able to see if there is a content entry on dependencies, it will be something like:
Comment #5
maaty388 CreditAttribution: maaty388 commentedI tested this patch and its working.
I added block Page title and it was not exported to the config because this is working just for block_content blocks.
Should depencies for blocks get exported as well?
Comment #6
Joao Sausen CreditAttribution: Joao Sausen at Dexa commentedIt is maybe a better idea to add a dependency to the block directly, if its a custom block, it will have a dependency in the block content already. What do you think? I will work on it when I have time.
Comment #7
maaty388 CreditAttribution: maaty388 commentedYes I think that will be much better :)
Comment #8
gambryNice work guys.
But
I thinkthe dependency calculation should live inside each Condition/Reaction plugin.The context calculateDependencies() should only collect the condition/reaction plugins instances dependencies and merge them to the parent::calculateDependecies(), if anyConfigEntityBase::calculateDependencies() already process each condition/reaction instance calculateDependencies(), it just a matter of adding some logic, as at the moment it just return an empty array .Comment #9
gambryAttached patch add dependencies for block using a PluginDependencyTrait(). This dependencies are only for the Blocks ContextReaction plugin.
It adds all required block dependencies: configs, content and modules.
This issue summary needs to be update, and maybe follow up must be create to add dependency for example on the selected theme for the Theme ContextReaction plugin.
Also settings 8.x-1.x as target branch due #2933080: 8.x-4.x branch is attached to 7.x code.
Comment #10
gambryUpdating the issue summary.
Comment #11
gambryUpdating the issue title to reflect what the work on this issue refers to (ContextReaction\Blocks dependencies).
Comment #12
BarisW CreditAttribution: BarisW at LimoenGroen commentedCan we have this patch in please? We need it on every project we work on, to make sure blocks created on a local environment will get created on other environments using config management
Comment #13
BarisW CreditAttribution: BarisW at LimoenGroen commentedPlease commit, so we don't have to use patches for our deployments anymore.
Comment #15
boshtian CreditAttribution: boshtian at Agiledrop - Your Trusted Drupal Teammates commentedComment #17
lamp5Hi quys. I think that something went wrong and this issue still exists. I can see that calculateDependency method is never called so we have no dependencies for our blocks. I tested patch from #2 and it works but need reroll.
Comment #18
paulocsI'll provide a patch for it.
Comment #19
manish-31 CreditAttribution: manish-31 for DrupalFit commentedI have created a reroll patch for 8.x-4.x, needs review.
Comment #20
paulocsI created a new patch to add the dependency.
The problem of patch #2 is that it calculates the block dependency in the context entity and it is not right IMHO.
In the patch that I attached, it adds dependency for conditions and reactions.
Please review it.
Comment #21
paulocsSmall documentation fix.
Comment #22
guilhermevp CreditAttribution: guilhermevp at CI&T commentedPatch #21 adds dependency successfully. Moving to RTBC and updating branch.
Comment #24
paulocsFixed!
Thanks.