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.

CommentFileSizeAuthor
#3 3431167-3.patch821 bytesdineshkumarbollu
Command icon 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

jrochate created an issue. See original summary.

jrochate’s picture

If there is no suggestion from someone more used to PbT, I will post my own patch in a couple of days.

dineshkumarbollu’s picture

StatusFileSize
new821 bytes

@jrochate

Added condition to fix the issue, please review and test the patch.Thanks

jrochate’s picture

I'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.

marcoliver made their first commit to this issue’s fork.

marcoliver’s picture

Status: Active » Needs review

I 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_bundles is used for one specific check only, which we're not going to pass anyway if $field_target_bundles has 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.

marcoliver’s picture

I went ahead and merged this. It's in dev now and will be included in the next release.

  • marcoliver committed 90755d69 on 3.1.x-dev
    Issue #3431167 by marcoliver, dineshkumarbollu, jrochate: TypeError:...
marcoliver’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.