Problem/Motivation
When using an entity reference view to load terms, we get a WSOD when editing node view mode.
Steps to reproduce
This is my use case, but I believe it can be reproducible with other cases:
- Create a vocabulary V and add terms VA, VB, VC
- Create a taxonomy view W of type Entity Reference, that is listing all V terms
- Create a paragraph P with a field F of type Taxonomy Reference that references W
- Create a node N with a paragraph field referencing P
Now, edit the display mode using Layout Builder.
The WSOD appears, before a warning and a fatal php error.
Proposed resolution
On src/Service/AccessChecker.php line 203 make sure that ['target_bundles'] exists.
If we debug the $field_definition->getSetting() we get this:
Array
(
[view] => Array
(
[view_name] => documentos_taxonomia_aux
[display_name] => entity_reference_1
[arguments] => Array
(
)
)
)
and because we are using an entity reference, there is no target_bundle chosen on the taxonomy field.
I haven't path'ed it because I don't know where is the best place to check field setting, so I leave it here for whom is more used to PbT.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3431167-3.patch | 821 bytes | dineshkumarbollu |
Issue fork permissions_by_term-3431167
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jrochate commentedIf there is no suggestion from someone more used to PbT, I will post my own patch in a couple of days.
Comment #3
dineshkumarbollu commented@jrochate
Added condition to fix the issue, please review and test the patch.Thanks
Comment #4
jrochate commentedI'm sorry, but I think that's not the solution.
You would have a warning about the non existing dimension of the array.
Also I don't the real implications of having the $field_target_bundles empty processed, instead of just skipping the code when empty.
I think we must wait for someone with a better knowledge about PbT. This is an access module, we shouldn't patch it to solve basic PHP errors without knowing the implications of some patch decisions.
Comment #7
marcoliverI have created a MR with a fix similar to what @dineshkumarbollu proposed, but also avoiding the warning @jrochate mentioned.
I believe providing an empty fallback value here in case there are no target_bundles defined is fine.
$field_target_bundlesis used for one specific check only, which we're not going to pass anyway if$field_target_bundleshas an empty value. Afterwards it is not used again.I played with the scenario a bit and the change does fix the error but does not seem to introduce any new issues.
I'd greatly appreciate it if somebody else could give the MR a quick look.
Comment #8
marcoliverI went ahead and merged this. It's in dev now and will be included in the next release.
Comment #10
marcoliver