- Issue created by @ajay547
- Status changed to Postponed: needs info
over 1 year ago 8:19pm 22 March 2023 Drupal.org is no longer accepting bug reports for Drupal 8. Drupal 8 reached end-of-life on November 2, 2021.
- ๐ฎ๐ณIndia ajay547
Hi @cilefen & larowlan
I have update my site to Drupal core 9.5.7
still I am facing the translation issue.
The nested paragraphs are allways loading in default language (en) and this is breaking my site's translation.
Any input or workaround here will be highly appreciated I am blocked on this.Thanks in Advance
I am glad you upgraded!
Please can you add to the issue summary the specific steps to reproduce the issue so the maintainers can have a look into this?
- ๐ฎ๐ณIndia ajay547
Hi cilefen,
Sure here is the summary for my issue.
I have a content type basic_page. It has one field of paragraph say A. Now one field of paragraph lets say field_B is again referencing to various paragraphs fields. Now If I am creating a node and in field_A selecting a paragraph field lets say field_C which has further paragraph reference in one of its field, then it is giving me translation issue.
This is happening only if I select field_B, for creaing my node, in case I am not referencing field B and referencing some other fields, then it is working fine. Now I am using JSONAPI to pull reference for the paragraph fields value through include parameter in JSONAPI.Thanks in Adavance.
- ๐ฎ๐ณIndia ajay547
I feel something is wrong in this piece of code
protected function resolveIncludeTree(array $include_tree, Data $data, Data $includes = NULL) {
$includes = is_null($includes) ? new IncludedData([]) : $includes;
foreach ($include_tree as $field_name => $children) {
$references = [];
foreach ($data as $resource_object) {
// Some objects in the collection may be LabelOnlyResourceObjects or
// EntityAccessDeniedHttpException objects.
assert($resource_object instanceof ResourceIdentifierInterface);
if ($resource_object instanceof LabelOnlyResourceObject) {
$message = "The current user is not allowed to view this relationship.";
$exception = new EntityAccessDeniedHttpException($resource_object->getEntity(), AccessResult::forbidden("The user only has authorization for the 'view label' operation."), '', $message, $field_name);
$includes = IncludedData::merge($includes, new IncludedData([$exception]));
continue;
}
elseif (!$resource_object instanceof ResourceObject) {
continue;
}
$public_field_name = $resource_object->getResourceType()->getPublicName($field_name);
// Not all entities in $entity_collection will be of the same bundle and
// may not have all of the same fields. Therefore, calling
// $resource_object->get($a_missing_field_name) will result in an
// exception.
if (!$resource_object->hasField($public_field_name)) {
continue;
}
$field_list = $resource_object->getField($public_field_name);
// Config entities don't have real fields and can't have relationships.
if (!$field_list instanceof FieldItemListInterface) {
continue;
}
$field_access = $field_list->access('view', NULL, TRUE);
if (!$field_access->isAllowed()) {
$message = 'The current user is not allowed to view this relationship.';
$exception = new EntityAccessDeniedHttpException($field_list->getEntity(), $field_access, '', $message, $public_field_name);
$includes = IncludedData::merge($includes, new IncludedData([$exception]));
continue;
}
$target_type = $field_list->getFieldDefinition()->getFieldStorageDefinition()->getSetting('target_type');
assert(!empty($target_type));
foreach ($field_list as $field_item) {
assert($field_item instanceof EntityReferenceItem);
$references[$target_type][] = $field_item->get($field_item::mainPropertyName())->getValue();
}
}
foreach ($references as $target_type => $ids) {
$entity_storage = $this->entityTypeManager->getStorage($target_type);
$targeted_entities = $entity_storage->loadMultiple(array_unique($ids));
$access_checked_entities = array_map(function (EntityInterface $entity) {
return $this->entityAccessChecker->getAccessCheckedResourceObject($entity);
}, $targeted_entities);
$targeted_collection = new IncludedData(array_filter($access_checked_entities, function (ResourceIdentifierInterface $resource_object) {
return !$resource_object->getResourceType()->isInternal();
}));
$includes = static::resolveIncludeTree($children, $targeted_collection, IncludedData::merge($includes, $targeted_collection));
}
}
return $includes;
}Here I am not able use $entity_storage->loadMultiple(array_unique($ids)) along with translation.
just for reference this is code from this file
web/core/modules/jsonapi/src/IncludeResolver.php - ๐ฎ๐ณIndia ajay547
Hi cilefen,
Thanks for your time and help, I found some help in this link.
https://www.drupal.org/project/drupal/issues/3088239 ๐ Revisions on relations are not loaded correctly resulting in wrong data in includes Needs workUpdating here as this could be helpfull for some one.
TIll Drupal 9.3 only revisions supported are file and node, after 9.3 update Drupal started support for paragraph revisions, so you need to bring your core above 9.3 and also you need to handle the permission (allow view revisions and allow view media revisions).
Thanks
Does this issue duplicate ๐ Revisions on relations are not loaded correctly resulting in wrong data in includes Needs work , or, should this issue be closed as โworks as designedโ?
- ๐ฎ๐ณIndia ajay547
Hi Cilefen,
Yes correct this issue is duplicate of this.Team this issue is duplicate of
https://www.drupal.org/project/drupal/issues/3088239 ๐ Revisions on relations are not loaded correctly resulting in wrong data in includes Needs work
just some additional points to remember here- Dont forget to update your Drupal core to atleast 9.3.0 in order to use this patch, because from 9.3.0 the core supposets revisions for paragraph and prior to that it supports only revision for node and media.
- You will need to handle view all revisions permission and view all media revisions. - Status changed to Closed: duplicate
over 1 year ago 6:34am 6 April 2023