Problem/Motivation
Currently it is impossible to check from outside the entity if it has been validated.
Proposed resolution
Introduce ContentEntityInterface::isValidated().
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | interdiff-2-3.txt | 680 bytes | hchonov |
| #3 | 2890333-3.patch | 2.23 KB | hchonov |
| #2 | 2890333-2.patch | 2.16 KB | hchonov |
Comments
Comment #2
hchonovComment #3
hchonovI've forgotten to install the entity schema and therefore the previous test is failing.
Comment #5
timmillwoodCan't see any reason not to do this.
Comment #7
hchonovIt has been a random failure. Setting back to RTBC.
Comment #8
larowlanWe can't add methods to an interface - its a BC break.
Comment #9
hchonovNo, it is not an API break. We are allowed to add new methods to interfaces, where a base class : interface relationship is provided and this is the case between ContentEntityBase and ContentEntityInterface. It is not an API break because according to our policy developers should extend from the base class instead implementing the interface. From https://www.drupal.org/core/d8-bc-policy:
And we've done this a lot of times already just look at the git annotations in e.g. ContentEntityInterface :).
Comment #10
larowlanHmm, I wasn't aware of that - it seems counter intuitive.
Will check with another committer.
Thanks for pointing it out.
Comment #11
catchThe documentation for that is here: https://www.drupal.org/core/d8-bc-policy#interfaces
We decided on allowing that (where there's a base class we expect every implementation to inherit from) to avoid having to add a new interface (and deprecation) every time we add a new method. In theory this would seem more disruptive than adding new interfaces, but in practice it's worked out well so far.
Comment #12
larowlanOk, can we have a change record describing the new functionality.
Then I think it's ready
Thanks
Comment #13
hchonovI've just created the change record - https://www.drupal.org/node/2895323.
Comment #14
timmillwoodThink we can go back to RTBC then?
Comment #15
timmillwoodShould the change record provide a possible use case or a real world example? I often find it much easier to understand something with an example.
Comment #16
xjmThe reason we need the CR is because of the BC break, so the CR should cover that. The method is being added to
ContentEntityInterface.ContentEntityBaseincludes a default implementation, so most content entity definitions won't be affected; however, anyone implementingContentEntityInterfacedirectly will now need to implement this method as well.This actually makes me wonder if this is the right interface for this method. The parent interface
FieldableEntityInterfaceis the one that provides the concept of validation. Should this method go there instead?Comment #17
hchonov@xjm, like pointed out in #9 and in #11 we add new methods to a base class where a 1:1 relationship interface : base class is provided. Adding the method to ContentEntityInterface is not considered an API or BC break, but adding it to FieldableEntityInterface is considered API break. This is why we add new methods to ContentEntityInterface instead to FieldableEntityInterface and in D9 we have to move the methods to the proper interfaces.
From #2862574-11: Add ability to track an entity object's dirty fields (and see if it has changed) :
Comment #18
hchonovComment #19
xjmThat makes sense. Thanks @hchonov. If the plan is to move them to the proper interface in D9, then let's please put @todos on them and create an explicit followup. (Also @see to the validation methods on the parent interface, because I had to go look for them.)
I thought a minute about how this would work in the continuous upgrade path. There isn't a BC break for implementors of CEI because they inherit the method when it's moved to the parent. But direct implementations of FEI are disrupted in this D9 change. I don't really think there's any way to mark a deprecation for this. Any thoughts on how we inform developers in advance in the continuous upgrade path model?
The CR updates will still be needed then also. We can include this information about moving the method in the future in the CR as well.
Thanks!
Comment #20
catchDifferent ways this could be done with the continuous upgrade path stuff:
1. Add the deprecation on ContentEntityInterface for 9.0.0 to be removed in 10.0.0
2. A new ContentEntityInterface in a different namespace with less methods, then ContentEntityInterface inherits from it in 8.x and not in 9.x
3. A new FieldableEntityInterface with the additional method. Have ContentEntityInterface inherit from the new interface, which in turn inherits from the old interface.
The trouble with #1 is that it's time-bound between opening 9.x and and releasing 9.0.0, and that it leaves the method until 10.0.0
The trouble with #2 is that for each method we want to remove from ContentEntityInterface, we could end up with a new interface in 8.x.
Trouble with #3 is it requires an instanceof check where FieldableInterface is type hinted and you want to use the new method, and it has the interface-proliferation drawback of #2.
Comment #22
hchonovI am not sure how we could inform developers about the changes we are going to make in D9 as there will be a lot of changes/rearrangements in the entity interfaces and in the entity storage interfaces. In #2926540: Split revision-handling methods to a separate entity storage interface we've already done some splitting regarding the entity storage interfaces.
This just became blocker for #2438017: Entity reference does not validate auto-created entities and also needs additional method for reseting the flag, as the other issue needs a way of finding if an entity has been already validated and if so skip re-validating it again - this however enforces that the code validating an entity also takes care of the validation errors, but if this is not possible then that code should be able to reset the validated flag.
Comment #34
smustgrave commentedThank you for sharing your idea for improving Drupal.
We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!