- Issue created by @nitesh624
- 🇮🇳India nitesh624 Ranchi, India
This seems to be broken after https://git.drupalcode.org/project/section_library/-/commit/f338ef84ae79... commit
- 🇺🇸United States jastraat
Reducing to normal since this relates to an interaction with custom code.
I will point out that paragraph cloning was broken prior to 🐛 Error after importing section/template that contains blocks with paragraphs without available source content Active for paragraphs in inline blocks where the inline block was saved as part of a layout before creating a section template and then the original source block was deleted.
It looks like the hook is targeting a media entity. How does that interact with the paragraph and block entities? Is there a media reference field on the paragraph?
- 🇮🇳India nitesh624 Ranchi, India
No Its not necessary that hook contain media entity.
If my hook is like below still its causing the failurefunction custom_media_entity_bundle_field_info_alter(array &$fields, EntityTypeInterface $entity_type, string $bundle): ?array { $fields = []; return $fields; }
And I found out why we are getting error here
The issue is in https://git.drupalcode.org/project/section_library/-/blob/2.0.0/src/Deep... line
$default_fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('paragraph', NULL);
So what I did I remove the above line and added below line within the foreach look just below it
$default_fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('paragraph', $paragraph->getType());
foreach ($value as $key => $item) { // createDuplicates() creates a duplicate with the same parent_id. // Our duplicate needs to be independent of original inline block id. $paragraph = $paragraph_storage->load($item['target_id']); $default_fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('paragraph', $paragraph->getType()); .... ....
Then Its working fine for me
- 🇮🇳India nitesh624 Ranchi, India
So the problem is:
Since inhook_entity_bundle_field_info_alter()
we are using typed parameter so whenever$default_fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('paragraph', NULL);
line executes, thehook_entity_bundle_field_info_alter()
hook also invoked and since 2nd parameter is passed NULL from section_library module. It breaks here due to type mismatched. - 🇺🇸United States jastraat
Thank you for that level of debugging and detail!
Does the attached MR address your issue?
-
jastraat →
committed a40d2fcf on 2.0.x
Issue #3515239 by jastraat, nitesh624: Cloning error for blocks...
-
jastraat →
committed a40d2fcf on 2.0.x