- Issue created by @catch
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
It's @larowlan who led us in this direction β see π Cannot delete JS components due to component depending on them Active for the history.
- π¬π§United Kingdom catch
I don't see any discussion of an uninstall validator in that issue. On a quick look, it looks like it's half dealing with components/plugins going missing (arbitrarily removed during development or via a module update) and half with module uninstall - but those are two very different scenarios because one is developer error and one is a site builder operation.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
You're right that plugins going missing is a developer error. This is also what @longwave called out in #3519168-14: Handle components provided by ComponentSources EXPLICITLY disappearing β enables deleting JS components that are in use β .
So, how did we go from that to seemingly conflating it with site builder operations?
I think because that issue was originally scoped only to disappearing
JavaScriptComponent
config entities (original title: ). See #3519168-12: Handle components provided by ComponentSources EXPLICITLY disappearing β enables deleting JS components that are in use β , in which I retitled, and the MR comments I posted just before that.From your POV, that's more of a "site builder operation", because no modules were updated, installed or uninstalled ("zero composer" if you will).
From quickly skimming that issue and some of its links, I pushed back against either a
js
Component Source-specific solution and against ansdc
-specific solution (in #3519168-48: Handle components provided by ComponentSources EXPLICITLY disappearing β enables deleting JS components that are in use β ).That's how we eventually ended up with the current
\Drupal\experience_builder\Entity\Component::onDependencyRemoval()
. I'm still not entirely convinced that what we have in0.x
is wrong though. I suspect a crystal-clear concrete example would help most? π€ - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
I think we probably need both, because as you pointed out there's a site builder operation and a module operation.
Thinking of the site builder operation, we've had lots of reports over the years of 'I removed this field and my (view|some other thing) was removed' so onDependencyRemoval is for that. Lauri made the original report in that he wanted to remove a Code component but was prevented from doing so because the code component was depended on by the component config entity.
But you're right, an uninstall validator should hard prevent someone from uninstalling a module and footgunning their content into the fallback plugin.
So I think that means we should limit Component::onDependencyRemoval to config dependencies and not module and theme ones - and cover those two with an uninstall validator.
I can take that on.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
I think
limit Component::onDependencyRemoval to config dependencies and not module and theme ones - and cover those two with an uninstall validator.
sounds reasonable. But I'll only know for sure once the full impact of that change is visible.
AFAICT this does not need to be a beta blocker, because it won't impact data storage aka π± [META] Production-ready data storage Active .
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
WRT full impact β there's a few major consequences I expect:
ContentTemplateDependencyTest::testRemoveFieldTypeProviderModule()
will change drastically β it'll be much more painful- β¨ Implement `::onDependencyRemoval()` for `Pattern` and `PageRegion` config entities: when a module providing a field type is uninstalled, replace it with the default StaticPropSource Active to get marked
- etc.
I think the commonality between those is: it's hard to find the specific component instance that depends on some dependency going missing (whether it's a field type or something else). IIRC that's why @lauriii advocated for this approach. But, I wish we had documented the rationale better π That's on me. Sorry.
(The best I can find is @longwave's RTBC at #3518336-43: When a field instance used by a `ContenTemplate` is deleted, or a field-type providing module is uninstalled, replace affected `inputs` with default `StaticPropSource` β after @lauriii's direction at #3518336-11: When a field instance used by a `ContenTemplate` is deleted, or a field-type providing module is uninstalled, replace affected `inputs` with default `StaticPropSource` β β but AFAICT @phenaproxima interpreted @lauriii's request more broadly.) - Merge request !1131Issue #3528723 Component uninstall validator for module/theme removals β (Merged) created by larowlan
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Got an MR up showing the hybrid approach, uninstall validator for modules/themes
Config dependency for config dependencies, during testing found that we weren't adding static prop source dependencies to the config entity so added that - this gave me a nice way to test fallback with media types.Will fix any fails tomorrow but I think the approach is ready for review
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Reviewed this together with @catch.
The behavior in HEAD is that a code component (
JavaScriptComponent
) that is in use in e.g. 1 article and 1 page can still be deleted. It requires a little bit of shenanigans though: you have to open a content entity in XB that does not contain an instance of that code component!If such an instance is present, you do get a nice error message/confirmation dialog:
On all other content entities (i.e. any with an XB component tree but without this particular code component), the deletion will proceed unceremoniously π β It's far too easy to shoot yourself in the foot right now!
The changes in this MR remove the "shoot yourself in the foot" case for:
- uninstalling modules providing block plugins
- uninstalling themes/modules providing SDCs
π
BUT concerns remain regarding code components β because this MR doesn't change anything (intentionally!) for those.
@catch and I agreed that:
- A confirmation dialog like the above should ALWAYS appear
- It should inform the user of how many entities/revisions would be impacted
- It should inform the user that if they proceed all existing content will look broken.
IOW: allow it only for developers who really know what they're doing, but present the consequences as explicitly as possible.
This strikes the middle ground of desire for reliability+consistency (@catch and I) vs pragmaticness when developing code components (@lauriii's concern).
In the future, if Drupal core gets a "developer mode", we could adjust the behavior based on that β see β¨ Add a Production/Development Toggle To Core Needs work .
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
After some more brainstorming with @catch, we think we thought of an alternative approach that actually is better still:
- add a
soft_deleted: true|false
config entity property toJavaScriptComponent
, which defaults tofalse
- make the
delete
operation either:- : actually delete (as is the case today)
- : set
soft_deleted: true
(π)
- make XB in all its API responses pretend this config entity does not exist
- β¦ then just respect all config dependency management as per usual
P.S.: an alternative/more refined approach could be that we make
JavaScriptComponent
implementVersionedConfigEntityInterface
(new since ~2 weeks) to keep the underlying config entity around, and only allow 2 versions: whichever one is the active one, plus a specialdeleted/trashed
version that gets treated everywhere in XB as if it doesn't exist. That way, we would not have to delete - add a
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
After #10 + #11, I also reviewed this.
This looks great! π
Pushed a single commit to try to clarify the thing I found most confusing, plus identified 2 renames that IMHO would clarify the situation a lot π€
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Clarification: #10 and #11 are out of scope here, just conclusions @catch and I reached while reviewing π
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Ok, addressed the review feedback, this is ready for another review.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Follow-up created for #10 + #11: π Only allow deleting Code Components if there's 0 usages Active .
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Placed the block in 1 content entity and in a region. If I then try to install the Views module (which provides that block):
and then if you click the :
Note that no message appears for the
PageRegion
config entity that also contains an instance of this component β because that's handled by config dependencies. π -
wim leers β
committed a5ff20a2 on 0.x authored by
larowlan β
Issue #3528723 by wim leers, larowlan, catch: Component::...
-
wim leers β
committed a5ff20a2 on 0.x authored by
larowlan β
Automatically closed - issue fixed for 2 weeks with no activity.