I got this notice when I'm adding a new media in an entity embedded in a paragraph (OK that's 3 levels of reference from the node).
Notice: Trying to access array offset on value of type null in Drupal\entity_browser\Element\EntityBrowserElement::valueCallback() (line 232 of modules/contrib/entity_browser/src/Element/EntityBrowserElement.php).
The error only happens when I submit the node form without clicking "Create entity" in that entity first.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | entity_browser-array-offset-value-null-3199269-17.patch | 641 bytes | ricovandevin |
| #14 | screenshot-for-entity-browser-notice.png | 13.8 KB | alison |
Issue fork entity_browser-3199269
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
jcisio commentedComment #3
rollins commentedI can confirm that #2 patch solved the problem.
Thanks jcisio.
Comment #4
chr.fritschYes, this is needed for PHP8 compatibility.
Comment #5
dave reidI see this pattern being used a lot in Drupal core's valueCallback() methods, including at https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21.... Is there an open issue for fixing those in Drupal Core that you could help point to?
Comment #6
dave reidThis looks to be the actual fix comparing against other core valueCallback() methods.
Comment #7
sylvainm commentedWell, patch from #6 does not fix the issue because $input is === NULL and not FALSE, so it does not hit the early return
Patch from #2 fixes the warning
Comment #8
rar9 commentedboth above patches are not working for Drupal 9.2.0 with Entity Browser 8.x-2.6
I´m still getting the below with or without patch.
Comment #9
bkosborneThose notices and warning seem unrelated
Comment #10
bkosborneThe first patch works for me.
Comment #11
mglamanThe problem is due to
$inputbeing null.I'd like to see a fix like this:
Comment #13
alisonI'm not sure the exact right status of this, but it's not "RTBC" anymore :)
Comment #14
alisonI just tried the MR 7 patch on our site (I think it was successful) -- our situation also involves excessive levels of referencing, but with ECK bundles, not paragraphs.
We have ECK entities embedded in WYSIWYG fields, using entity_embed and embed_button -- and entity_browser gets used along the way, too. We get the notice described in this issue (
Trying to access array offset on value of type null in...) after selecting an entity to embed -- in other words, when we're back in the smaller modal/dialog, right before getting back "into" the WYSIWYG field, if that makes sense (screenshot attached -- the lack of a thumbnail of the selected entity in this dialog is a separate issue, as far as we know -- something about a limitation of how ECK works with our other entity/embed modules).We only get the notice when initially embedding the entity -- if I double-click on a previously embedded entity (in WYSIWYG), there's no notice.
I think our situation is actually quite similar to the original author, except that in our case, the extra levels of referencing come from ECK, not paragraphs. The notice only happens when embedding an ECK entity where there's an entity browser within an entity browser, basically -- like, we have a few "simpler" ECK bundles that also get embedded in WYSIWYG fields via embed buttons, but they don't trigger notices in dblog -- only the situations where we're three (or four??) levels deep.
-------
I'm going to try to explain -- I hope it makes enough sense! (oh and, I know this setup is horribly convoluted; all I can say is, we sure wish it weren't like this 😖)
-------
With the MR 7 patch, the notice is gone. I don't know if there are other issues, but the notice is gone, so I figured I'd share my story.
Comment #16
swentel commentedPatch fixes the notice, yet the image is (still) gone.
Our setup is a block with paragraph which has an image field, within layout builder.
Selecting/uploading goes fine, but when we want to add another delta, the second delta appears, but the uploaded/selected image is gone on the first delta.
This started after updating to D9.2.9 recently - coming from latest D8, where it worked perfectly. Might be LB related, but not sure of course.
Note: using that paragraph on a node, the default value of the image is fine, so it's in combination with LB.
update The notice might be a red herring when it comes our problem, revering to 8.x-2.5 and still the same problem, so sorry for the noise.
Comment #17
ricovandevin commentedAttaching patch created from MR #7 to support Composer based workflows.
Comment #18
carolpettirossi commentedIn my case, the Remove button was not working as expected an patch #17 (or MR #7) solved it.
Comment #19
dave reidComment #21
dave reidTested and merged to 8.x-2.x.