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.

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

jnicola created an issue. See original summary.

jnicola’s picture

StatusFileSize
new806 bytes

Attaching the patch that works for us. Just sanity chicks first() isn't null. More is likely needed.

damienmckenna’s picture

Version: 8.x-2.0 » 8.x-2.x-dev
Status: Active » Needs review
tvalimaa’s picture

#2 patch worked for me on this

The website encountered an unexpected error. Please try again later.
Error: Call to a member function mainPropertyName() on null in Drupal\media_entity_instagram\Plugin\media\Source\Instagram->matchRegexp() (line 249 of modules/contrib/media_entity_instagram/src/Plugin/media/Source/Instagram.php).
it-cru’s picture

Version: 8.x-2.x-dev » 3.x-dev
Priority: Normal » Major
Status: Needs review » Needs work

Issue already exists in 3.x branch.

it-cru’s picture

Status: Needs work » Needs review

Opened MR for 3.x branch. Untouched patch for 2.x.

chr.fritsch made their first commit to this issue’s fork.

  • chr.fritsch committed 7cce8cc on 3.x authored by IT-Cru
    Issue #3143310 by IT-Cru, jnicola: Issue with paragraphs, Drupal\...
chr.fritsch’s picture

Status: Needs review » Fixed

Thx

Status: Fixed » Closed (fixed)

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