When the call of the $entity.save() fails an exception is thrown. This exception is not handled and reaches the client (browser). The execution stops.

Instead of that we could handle the exception, log it in Drupal's logs and continue with the import of the rest entities.

Comments

skounis created an issue. See original summary.

skounis’s picture

skounis’s picture

StatusFileSize
new4.24 KB
skounis’s picture

Issue summary: View changes
skounis’s picture

Status: Active » Patch (to be ported)
skounis’s picture

skounis’s picture

StatusFileSize
new4.86 KB
berdir’s picture

Status: Patch (to be ported) » Needs review
andypost’s picture

Version: 8.x-1.0-alpha8 » 8.x-1.x-dev
Issue tags: +Needs reroll
andypost’s picture

Status: Needs review » Needs work
  1. +++ b/default_content.services.yml
    @@ -13,3 +13,6 @@ services:
    +  logger.channel.default_content:
    

    new service needs post_update hook to rebuild container

  2. +++ b/src/Importer.php
    @@ -100,8 +109,16 @@ class Importer implements ImporterInterface {
    +                              LoggerInterface $logger = NULL) {
    
    @@ -109,6 +126,14 @@ class Importer implements ImporterInterface {
    +    $this->logger = $this->createLogger($logger);
    

    nor sure it needs this BC, I found no other contrib which overrrides the service

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new5.11 KB
berdir’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

I've recently created the 2.0.x branch, see the project page on all the improvements in the 2.0.x branch. The 1.x branch isn't actively maintained and won't receive new features anymore, so moving this over to 2.0.x. Agree that this would be good to have.

Will need a reroll however.

ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new5.58 KB

Rerolled the patch in #11 to 2.0.x.

johnwebdev’s picture

Do you really want to continue with importing potential broken content? I'm thinking instead we should use transactions, and rollback all content being imported if any exception occur.

andypost’s picture

Moreover to broken content you can also get commits from dblog or custom modules.

Trying to use transactions is very fragile way with a tons of workarounds and compromise... I'd say just throw exception and fix content or code

a.hover’s picture

StatusFileSize
new5.29 KB

Rerolled the patch in #13 to the latest version of 2.0.x.

c_archer’s picture

Patch in #16 fails against the latest dev release.

a.hover’s picture

StatusFileSize
new5.47 KB

Rerolled the patch in #16 to the latest version of 2.0.x.

a.hover’s picture

StatusFileSize
new5.46 KB

Rerolled the patch in #17 to the latest version of 2.0.x