Finding an issue with this module in our particular instance.
Recreation:
Create a paragraph with instagram field
Create a different paragraph type, something simple ideally for testing.
Have a content type with a field allowing both of the previous paragraphs types.
Create a piece of content of the new content type, add instagram paragraph
Attempt to add another paragraph. Ajax fails, and you get an error: cannot call method mainPropertyName() on null.
Cause:
You can't rely on first, ever. Always sanity check first exists.
$property_name = $media->{$source_field}->first()->mainPropertyName();
Anytime you use first, and haven't sanity checked it, you run the risk that first() returns null and then you're trying to access a method on NULL.
There is likely a larger issue at play here. Why source field fails, why it's getting null, why all of that is happening I don't know at this time. For now, for my purposes, simply adding a sanity check works.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | if-youre-not-first-youre-null-3143310-1.patch | 806 bytes | jnicola |
Issue fork media_entity_instagram-3143310
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
jnicola commentedAttaching the patch that works for us. Just sanity chicks first() isn't null. More is likely needed.
Comment #3
damienmckennaComment #4
tvalimaa commented#2 patch worked for me on this
Comment #5
it-cruIssue already exists in 3.x branch.
Comment #7
it-cruOpened MR for 3.x branch. Untouched patch for 2.x.
Comment #10
chr.fritschThx