- Merge request !5Issue #2698425: Do not reimport existing entities → (Open) created by eduardo morales alberti
- First commit to issue fork.
- First commit to issue fork.
- 🇳🇱Netherlands eelkeblok Netherlands 🇳🇱
Thanks for all the work everyone. While trying to get a project moved over to default content 2.x and tinkering around with this issue as well as ✨ Allow manual imports Postponed , I found that the code for this issue basically completely ignores the legacy json files, because the logic has been implemented in the denormalize() method of the content entity normalizer, which exclusively deals with YAML files. The code branch for json is higher op, in the importContent method of the importer class. I tried looking through this issue whether that was a deliberate decision, but I couldn't find any mention of it. To me this "smells" a little, it should really matter what format the input is in for this functionality to do its thing. Of course, when json support is completely removed this might all go away... Thoughts?
- last update
over 1 year ago 17 pass - Status changed to Needs review
over 1 year ago 2:39pm 8 May 2023 - 🇧🇬Bulgaria pfrenssen Sofia
Replying to the comment from @eelkeblok in #2698425-187: Do not reimport existing entities → :
I found that the code for this issue basically completely ignores the legacy json files, because the logic has been implemented in the denormalize() method of the content entity normalizer, which exclusively deals with YAML files. The code branch for json is higher op, in the importContent method of the importer class. I tried looking through this issue whether that was a deliberate decision, but I couldn't find any mention of it. To me this "smells" a little, it should really matter what format the input is in for this functionality to do its thing. Of course, when json support is completely removed this might all go away... Thoughts?
This issue got raised before. It was suggested by @berdir in comment #2698425-161: Do not reimport existing entities → that the old JSON format is basically unsupported and developers should update to YAML format when updating to 2.x.
default_content 8.x-1.x is also basically unsupported and 2.0.x uses a custom serialization format that does not use the serialization API at all and I strongly suggest to update to that.
Since there never was support for updating existing entities in 1.x and there never will be, there is no real reason to include JSON support in this issue. I agree that it would help to make the upgrade process smoother for people who were already using an early version of this patch for 1.x, but that shouldn't block adoption of this issue.
All remarks have been addressed, setting back to needs review.
- 🇧🇪Belgium johanvdr
Should we not check for existing entities and update them instead of recreating all?
- 🇨🇭Switzerland Mistrae
Patch #173 works well. On the contrary with MR 14, if I import 2 different nodes with same images and medias on 2 different modules, one node has no image.
- last update
over 1 year ago 13 pass - 🇧🇬Bulgaria pfrenssen Sofia
@Mistrae thanks for the report. Could you possibly provide a test case that shows the bug? Or more details on how this can be replicated?
Could not apply the patch after upgrading to 2.0@alpha. Is it because the HAL module is made optional in the new version?
- Status changed to Needs work
9 months ago 11:08am 20 February 2024 Thanks for patch #175, we have tested it on drupal 9.5. And it works correctly.
Be careful with changing ID during import.
- 🇧🇯Benin delacosta456
hi
also thanks for #175 .. it's working on D10.2.5 with php8.2 - 🇪🇸Spain unstatu
Hello everyone,
I have been struggling with the same problem that was mentioned by stamina in https://www.drupal.org/project/default_content/issues/2698425#mr14-note2... 🐛 Do not reimport existing entities Needs review .
The way to reproduce the problem is:
- Create a layout
- Place an inline block_content with an entity reference field to one or several media images
- Export the node where the layouts was created (including its dependencies)
- If you try to import the node in a different environment, the block_content loses its references to the media entities. Media entities are created correctly but the entity_reference field in the block_content entity is empty.I have created a patch file based on the current status of the MR!14 adding the fix that he suggested.
- 🇻🇳Vietnam thanhdo1991
Some cases, we need to call importContent method without config directory. This patch file make more parameters for custom path
- 🇧🇯Benin delacosta456
hi @unstatu
thanks for the patch that applied correctly on D10.2 +php8.2
However on my own side when updating the node's section (in layout builder), changes will not be reflected in another env until i delete the node and import again by enabling the custom module.This looks to be also the case for other entities like menu_link_content.(Ex have menu link X in both environment Adev and Bprod. on Adev, change the label and disable the menu link, and finally export. there will be no change )
it' looks like #175 approach is the only one that is successfully uptating an entity
- 🇧🇯Benin delacosta456
hi all
@andypost
@lammensj
@eelkeblok
@kalpaitch
@nedjo
@pfrenssen
@jomsyCan somebody please help me know how to use the
$update_existing
variable (setting it to true ) when re-enabling DC-custom-module to fire entities update?Thanks
- First commit to issue fork.
- Merge request !48Issue #2698425: Delete the existing content and import the new one. → (Open) created by rajdip_755
- last update
5 months ago 14 pass - Status changed to RTBC
5 months ago 9:52am 3 July 2024 - 🇵🇱Poland bronismateusz
I confirm, the import problems were solved by the patch from #196. 🐛 Do not reimport existing entities Needs review
- Status changed to Needs work
3 months ago 10:14pm 23 August 2024 - 🇨🇭Switzerland berdir Switzerland
+++ b/src/Normalizer/ContentEntityNormalizer.php @@ -178,18 +179,45 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface { + return $entity; + } + // Adding support for Entity Reference Revisions entities. This is used by + // popular contrib modules such as Paragraphs and Commerce. + // @todo Drop the method_exists() call once + // https://www.drupal.org/project/entity_reference_revisions/issues/3336752 + // is fixed. + elseif ($entity instanceof EntityNeedsSaveInterface && method_exists($entity, 'setNeedsSave')) { + $entity->setNeedsSave(TRUE); + }
the issue is now committed, would conflict if an older version is used, one option would be to add a conflict to composer.json, not sure if that's worth it.
The created merge request is for #197, not #196. Please create the correct MR so that tests on CI can run with this.
Looks like a version of this is already in the core importer API.
- First commit to issue fork.
- 🇦🇺Australia silverham
[Do not commit]
Uploading patch file for Acquia starter kit since it depended on a merge request patch which was updated but I believe it should of depended on uploaded patch file instead to avoid the issue in the future. - 🇦🇺Australia silverham
[Do not commit - for version 2.0.0-alpha3 only]
Uploading patch file2698425-do-not-re-import-existing-entities--acquia-starter-kit--2-0-0alpha3-2024-08-30.patch
for Acquia starter kit since it depended on a merge request patch which was updated but I believe it should of depended on uploaded patch file instead to avoid the issue in the future. - First commit to issue fork.