Problem/Motivation
In the Dynamic Entity Reference module, somewhere between Drupal 8.2 and 8.5.x, this issue has appeared: #2908109: Entity queries broken for non-DER entity reference base fields. It is due to #2424791: Entity query hardcodes entity_reference and entity specifier, and DER's overriding of the addNextBaseTable method. DER is unable to check if the field referencing the table and column to be added is a normal entity_reference field (in which case it should do nothing) or a dynamic_entity_reference field, in which case it should change the column to utilize the _int column.
Proposed resolution
If the protected method addNextBaseTable had the field storage object passed to it, DER could work around this issue by checking that the referencing field was a dynamic_entity_reference field, and not a normal entity reference.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | pass_field_storage_to-2908605-22.patch | 1.43 KB | jibran |
Comments
Comment #2
jhedstromComment #3
jhedstromComment #4
jibranIt is a contrib project blocker, is there a chance that this can be committed to 8.4.x as well?
Comment #5
xjmI'd really like an Entity subsystem maintainer review on this one. Thanks!
Comment #6
xjmNR for them; if they sign off it can go back to RTBC.
Comment #7
amateescu commentedThis looks ok to me. The
addNextBaseTable()method was added specifically for DER in #2808333: Factor out the join from Tables.php but it seems that it is not very useful for them without this additional parameter.Comment #8
xjmThanks @amateescu!
Comment #9
xjmAh, this would need a small CR as a parameter addition to a protected method. It could cause BC breaks for a child implementation that overrode this method and added a different fourth parameter already. The BC break is allowable though since this method is not on
TablesInterface. (I don't think we should backport it during RC, though, because there is a very small chance it could break something. Edit: Except that I forgot that this is also a contrib blocker per the IS, duh.)Still, #2808333: Factor out the join from Tables.php should probably have had a CR, and it doesn't look like it did. Let's add a single CR for both that and this?
Comment #10
xjmComment #11
xjmHow bad is this issue for DER? Since it is a slightly disruptive change. I wonder if there is a way to fix it that doesn't require an internal BC break?
Comment #12
jibranThank you @amateescu for looking into it and pointing out to the original issue in which the method was added. Thank you @xjm for giving it a thorough review and pointing out the issues.
Added change notice https://www.drupal.org/node/2909405. Accommodate the BC as well.
Comment #13
jibranIn DER 8.x-2.x, when in EFQ you try to add a condition on the property of base ER field it errors out this means it is broken for every entity with the author field so almost all entities.
For example following query is broken when DER 8.x-2.x is installed:
For more details please see IS of #2908109: Entity queries broken for non-DER entity reference base fields.
Comment #14
jibranIgnore the patch in #12 this is patch is with BC.
Comment #15
jibranNow DER can do this.
Comment #16
jibranUpdate the change record as well with the new approach. We might need another subsystem maintainer review.
Comment #17
xjmAh yeah that is more backportable! I can't think of any way that would break anything. The chances of anything else overriding the caller and already passing an undeclared extra argument of a different data type and doing its own
func_get_arg()are well and truly miniscule.I think we should add an inline comment explaining why we're passing an extra argument, with an @todo to a followup issue.
There's two things the followup issue could be. Since this is a protected method not on a corresponding interface, our BC policy allows us to change it in a minor release if we want. The full BC thing to do would be to deprecate the method and add a new one with the new signature. However, that seems unnecessary to me; just wanted to document that I'd thought it through.
Tagging again per #16.
Comment #18
xjmMoving to 8.4.x; I'm fairly confident we are fine with the new approach during RC. I'd even consider it during a patch release.
Comment #19
jibranThank you once again @xjm for giving it a thorough review. I added the docs, created the follow-up #2909425: Add the $field_storage parameter to Tables::addNextBaseTable and update the change notice. Have you reviewed the change notice as well?
Comment #20
jibranImproved the wording a little.
Comment #21
amateescu commentedThis whole paragraph sounds a bit.. non-english :) I would suggest something like this instead:
An additional $field_storage argument is being passed to addNextBaseTable() in order to improve its functionality, for example by allowing extra processing based on the field type of the storage. In order to maintain backwards compatibility in 8.4.x, the new argument has not been added to the signature of that method, and it will be added only in 8.5.x.
@todo Add the $field_storage argument to addNextBaseTable() in 8.5.x: https://www.drupal.org/node/2909425.
Comment #22
jibranSure here we go.
Comment #23
amateescu commentedOk, let's do this :)
Comment #26
xjmGreat, that works. The change record also looks like it explains this pretty well. Committed to 8.5.x and cherry-picked to 8.4.x. I published the change record and updated its "fixed in version" stuff.