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.
The last dev gives me this error:
Error: Call to a member function label() on null in Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->addCollapsedSummary() (line 1470 of modules\contrib\paragraphs\src\Plugin\Field\FieldWidget\ParagraphsWidget.php)
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-2851860-12.txt | 3.52 KB | thenchev |
#12 | error_call_to_a_member-test_only-2851860-12.patch | 1.94 KB | thenchev |
#12 | error_call_to_a_member-2851860-12.patch | 2.63 KB | thenchev |
#8 | error_call_to_a_member_test-only-2851860-8.patch | 1.58 KB | thenchev |
#8 | error_call_to_a_member-2851860-8.patch | 2.27 KB | thenchev |
Comments
Comment #2
miro_dietikerSounds at least major.
However, we have great passing test coverage.
How can we reproduce your situation.
Comment #3
heyyo CreditAttribution: heyyo commentedThis error came just after installing the last dev version. It occurs only on node edition page which contains one paragraph field already filed with content from nested paragraphs.
Downgrading to previous dev version fixed my issue(the one of 4/5 days ago)
Comment #4
miro_dietikerYeah there was a recent fix that we use label of entity reference fields to populate the summary.
That code doesn't check the interface while not all entities (for instance config targets) do not have a label. Also not sure if we properly check if the entity load succeeded in the field item. (Problem stale field items where entities could be deleted)
Needs a fix and better test coverage.
Comment #5
thenchev CreditAttribution: thenchev commentedI can take a look.
Comment #6
thenchev CreditAttribution: thenchev commentedIt would probably help a lot if i get some more information, if someone has been thinking about this, when this can happen. Is having config targets the only situation?
I will test in the meantime.
Comment #7
Berdirif ($field_type = $value->getType() == 'entity_reference') {
if (!in_array($key, ['type', 'uid', 'revision_uid'])) {
$summary[] = $paragraphs_entity->get($key)->entity->label();
}
}
There isn't really a way to check it, best we can do is a fallback for the ID. Not the problem here, it would just result in an empty string if there is no label.
This however is exactly the problem. Check with if (...->entity) before calling a method on it.
To reproduce, just delete the entity we're using for testing this, then reload the edit form with it closed.
Comment #8
thenchev CreditAttribution: thenchev commented@Berdir thanks
There might be a better place for the test but didn't find any obvious space?
Comment #10
thenchev CreditAttribution: thenchev commentedComment #11
BerdirAbout the test, the code that added that also added tests: #2850788: Add test for collapsed user Paragraph summary, I would just expand on that.
Comment #12
thenchev CreditAttribution: thenchev commented@Berdir
Yea, makes sense. Wanted to avoid having to create paragraph type and configuring it but not that much extra code. Thanks again.
Comment #14
thenchev CreditAttribution: thenchev commentedComment #16
miro_dietikerCommitted with a comment. Thx.