Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#18 | 3015259-18.patch | 914 bytes | jrockowitz |
| |||
#17 | 3015259-17.patch | 951 bytes | jrockowitz |
| |||
#16 | 3015259-16.patch | 951 bytes | jrockowitz |
#15 | getEntityTypeId_on_null-3015259-15.patch | 951 bytes | spoit |
#12 | getEntityTypeId_on_null-3015259-12.patch | 866 bytes | spoit |
Comments
Comment #2
tamnv CreditAttribution: tamnv commentedPlease check and review this patch
Comment #3
tamnv CreditAttribution: tamnv commentedComment #4
tamnv CreditAttribution: tamnv commentedComment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedLooks good. Thanks for the patch.
Comment #6
tamnv CreditAttribution: tamnv commentedThank you! When is it available on dev version?
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI tend to tag new releases at the beginning of each month.
Comment #8
tamnv CreditAttribution: tamnv at FFW commentedThis issue still happens on new releases version, It also happens on dev version.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI messed up and did not properly commit the patch. #9 confirm that the patch was committed.
Comment #12
spoit CreditAttribution: spoit at Wieni commentedThis string comparison crashed on our end when using a custom entity called 'paragraphs'
Would an instanceof not have been better?
Comment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #14
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI just realized why I used
$type == 'paragraph'
instead ofinstanceof
. 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')
Comment #15
spoit CreditAttribution: spoit at Wieni commentedUpdated (untested, we don't use paragraphs)
Comment #16
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedSince we now using instanceof, we can simplify the patch.
Comment #17
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedDoh! I can't seem to upload my patch correctly.
Comment #20
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch
Comment #21
spoit CreditAttribution: spoit at Wieni commentedQuick work! Thx!