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)

Comments

heyyo created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major
Status: Active » Postponed (maintainer needs more info)

Sounds at least major.
However, we have great passing test coverage.
How can we reproduce your situation.

heyyo’s picture

This 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)

miro_dietiker’s picture

Status: Postponed (maintainer needs more info) » Active

Yeah 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.

thenchev’s picture

Assigned: Unassigned » thenchev

I can take a look.

thenchev’s picture

It 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.

berdir’s picture

if ($field_type = $value->getType() == 'entity_reference') {
if (!in_array($key, ['type', 'uid', 'revision_uid'])) {
$summary[] = $paragraphs_entity->get($key)->entity->label();
}
}

That code doesn't check the interface while not all entities (for instance config targets) do not have a 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.

Also not sure if we properly check if the entity load succeeded in the field item.

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.

thenchev’s picture

Status: Active » Needs review
StatusFileSize
new2.27 KB
new1.58 KB

@Berdir thanks
There might be a better place for the test but didn't find any obvious space?

Status: Needs review » Needs work

The last submitted patch, 8: error_call_to_a_member_test-only-2851860-8.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
berdir’s picture

About the test, the code that added that also added tests: #2850788: Add test for collapsed user Paragraph summary, I would just expand on that.

thenchev’s picture

@Berdir
Yea, makes sense. Wanted to avoid having to create paragraph type and configuring it but not that much extra code. Thanks again.

Status: Needs review » Needs work

The last submitted patch, 12: error_call_to_a_member-test_only-2851860-12.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review

  • miro_dietiker committed 26c7572 on 8.x-1.x authored by Denchev
    Issue #2851860 by Denchev, heyyo: Error: Call to a member function label...
miro_dietiker’s picture

Status: Needs review » Fixed

Committed with a comment. Thx.

Status: Fixed » Closed (fixed)

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