Automatically closed - issue fixed for 2 weeks with no activity.
When I place a paragraph field in the Layout Builder with the formatter "Paragraphs table" and table mode "Bootstrap Table" the layout builder crashes. When reloading the page, the following errors appear:
First this error appears:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getEntityTypeId() on null in Drupal\paragraphs_table\Plugin\Field\FieldFormatter\ParagraphsTableFormatter->getPreparedRenderedEntities() (line 808 of modules/contrib/paragraphs_table/src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php).
Drupal\paragraphs_table\Plugin\Field\FieldFormatter\ParagraphsTableFormatter->getPreparedRenderedEntities('paragraph', 'padde_acoes', Array, Array, Array, 'default', 1) (Line: 359)
Drupal\paragraphs_table\Plugin\Field\FieldFormatter\ParagraphsTableFormatter->viewElements(Object, 'pt-pt') (Line: 89)
Drupal\Core\Field\FormatterBase->view(Object, 'pt-pt') (Line: 76)
Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 263)
...
When fix the above error, this error appears:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "entity_id" for route "paragraphs_item.add_page" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 203 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('paragraphs_item.add_page', Object, Array, Array) (Line: 292)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('paragraphs_item.add_page', Array, Array, 1) (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('paragraphs_item.add_page', Array, Array, 1) (Line: 765)
...
It's a PHP8.1 + Drupal 9.4.5 installation
Make a validation if the entity id exists before using.
For the first error described, we must validate if an entity exists before adding operations:
if ($show_operation && $parent = $entity->getParentEntity()) {
$entityType = $parent->getEntityTypeId();
if ($entityType == 'paragraph') {
$entityType = 'paragraphs_item';
}
$destination = implode('/', [
$entityType,
$parent->id(),
]);
$operation = $this->paragraphsTableLinksAction($paragraphs_id, $destination);
$rows[$delta]['data']['operation'] = $operation;
}
For the second reported error, you must validate if the $entityId
variable is filled:
if (($hasPermission && $this->customPermissions['create']) || in_array('administrator', $userRoles) && $entityId) {
$destination = \Drupal::service('path.current')->getPath();
$dialog_width = 800;
$addButton = [
'#type' => 'container',
'add-button' => [
'#type' => 'link',
'#title' => Markup::create('<i class="bi bi-plus" aria-hidden="true"></i> ' . $this->t('Add')),
'#url' => Url::fromRoute('paragraphs_item.add_page', $params = [
'paragraph_type' => $targetBundle,
'entity_type' => $field_definition->getTargetEntityTypeId(),
'entity_field' => $fieldName,
'entity_id' => $entityId,
],
...
];
...
}
In this approach we guarantee that actions related to an entity only appear when this entity exists.
None.
None.
None.
None.
Fixed
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Automatically closed - issue fixed for 2 weeks with no activity.