Hi all,

Problem

We have a paragraph type Form Text that include a webform field. When we create a new node with paragraph Form Text and click on Preview, we got these errors:

  • Call to a member function getEntityTypeId() on null in Drupal\webform\Plugin\WebformSourceEntityManager::getMainSourceEntity()
  • Call to a member function getEntityTypeId() on null in Drupal\webform\Plugin\Field\FieldFormatter\WebformEntityReferenceEntityFormatter->viewElements()

Proposed resolution

We should check $source_entity before call member function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tamnv created an issue. See original summary.

tamnv’s picture

Please check and review this patch

tamnv’s picture

Assigned: tamnv » Unassigned
tamnv’s picture

Status: Active » Needs review
jrockowitz’s picture

Status: Needs review » Fixed

Looks good. Thanks for the patch.

tamnv’s picture

Thank you! When is it available on dev version?

jrockowitz’s picture

I tend to tag new releases at the beginning of each month.

tamnv’s picture

Version: 8.x-5.0-rc26 » 8.x-5.x-dev
Status: Fixed » Needs work

This issue still happens on new releases version, It also happens on dev version.

  • jrockowitz committed 29a4693 on 8.x-5.x authored by tamnv
    Issue #3015259 by tamnv: Call to a member function getEntityTypeId() on...
jrockowitz’s picture

Status: Needs work » Fixed

I messed up and did not properly commit the patch. #9 confirm that the patch was committed.

Status: Fixed » Closed (fixed)

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

spoit’s picture

This string comparison crashed on our end when using a custom entity called 'paragraphs'

Would an instanceof not have been better?

jrockowitz’s picture

Status: Closed (fixed) » Active
jrockowitz’s picture

Status: Active » Fixed

I just realized why I used $type == 'paragraph' instead of instanceof. Using instanceof requires the paragraph module to be installed.

The code would have to use...

($source_entity instanceof Drupal\paragraphs\Entity\Paragraph) && \Drupal::moduleHandler()->moduleExists('paragraphs')

spoit’s picture

Updated (untested, we don't use paragraphs)

jrockowitz’s picture

Status: Fixed » Needs review
FileSize
951 bytes

Since we now using instanceof, we can simplify the patch.

jrockowitz’s picture

jrockowitz’s picture

Doh! I can't seem to upload my patch correctly.

  • jrockowitz authored 670a2be on 8.x-5.x
    Issue #3015259 by jrockowitz, spoit, tamnv: Call to a member function...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch

spoit’s picture

Quick work! Thx!

Status: Fixed » Closed (fixed)

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