I was not able to reproduce the issue on vanilla installation, but happens every time on our project.

Drupal Version

10.6.2

Domain module version

2.0.x-dev and 2.0.0-rc1

Expected Behavior

No fatal PHP error, reloading the error page should not delete the source page!

Actual Behavior

Step 5. and 6.

Steps to reproduce

1. Create article content type in Finnish, translate the article to English.
2. Go to English content /en/node/{nid}/edit and press "Delete translation" link.
3. Url is /en/node/{nid}/delete?destination=/en/node/{nid}/edit
4. Confirm deletion by pressing "Delete English translation" button.
5. Translation gets deleted (on database level), but we get PHP error: "InvalidArgumentException: The entity object refers to a removed translation (en) and cannot be manipulated."
On logs there's also:
InvalidArgumentException: The entity object refers to a removed translation (en) and cannot be manipulated. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 609 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Warning: Undefined array key "en" in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 608 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php)
Warning: Trying to access array offset on null in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 608 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php)
6. Reload the page /en/node/{nid}/delete?destination=/en/node/{nid}/edit and also the Finnish source node is deleted and user goes to 404 page.

CommentFileSizeAuthor
#2 3568699-catch-exception.patch1.18 KBsokru

Issue fork domain-3568699

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sokru created an issue. See original summary.

sokru’s picture

Issue summary: View changes
StatusFileSize
new1.18 KB

Attached a patch that works for us.

mably’s picture

Status: Active » Postponed (maintainer needs more info)

Without a reproducible scenario on a fresh Drupal instance we won't be able to help much.

mably’s picture

Looks like an easy fix though.

Let's see what we can do here.

mably’s picture

Hi @sokru, can you give a try to this issue's MR?

Not sure we want to log anything if it's a normal behavior in fact.

Can you tell us more about it?

  • mably committed 312a0f67 on 2.0.x
    fix: #3568699 InvalidArgumentException: The entity object refers to a...
sokru’s picture

@mably thanks for the swift reply. The MR removes the fatal error, but there's two warnings

Warning: Undefined array key "en" in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 608 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(608): _drupal_error_handler()
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(597): Drupal\Core\Entity\ContentEntityBase->getTranslatedField()
#3 /var/www/html/web/modules/contrib/domain/domain_source/domain_source.module(118): Drupal\Core\Entity\ContentEntityBase->get()
#4 /var/www/html/web/modules/contrib/domain/domain_source/domain_source.module(143): _domain_source_get_source_domain()
#5 /var/www/html/web/modules/contrib/domain/domain_source/src/HttpKernel/DomainSourcePathProcessor.php(169): domain_source_get()
#6 /var/www/html/web/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php(108): Drupal\domain_source\HttpKernel\DomainSourcePathProcessor->processOutbound()

and

Warning: Trying to access array offset on null in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 608 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(608): _drupal_error_handler()
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(597): Drupal\Core\Entity\ContentEntityBase->getTranslatedField()
#3 /var/www/html/web/modules/contrib/domain/domain_source/domain_source.module(118): Drupal\Core\Entity\ContentEntityBase->get()
#4 /var/www/html/web/modules/contrib/domain/domain_source/domain_source.module(143): _domain_source_get_source_domain()
#5 /var/www/html/web/modules/contrib/domain/domain_source/src/HttpKernel/DomainSourcePathProcessor.php(169): domain_source_get()
#6 /var/www/html/web/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php(108): Drupal\domain_source\HttpKernel\DomainSourcePathProcessor->processOutbound()
mably’s picture

Geez, looks like I messed up and pushed another fix directly on branch 2.0.x...

  • mably committed 16b0d343 on 2.0.x
    Revert "fix: #3568699 InvalidArgumentException: The entity object refers...

mably’s picture

@sokru can you try MR 305 and see if it fixes your problem?
I tried a more targeted approach.

Hopefully it should get rid of those warnings.

mably changed the visibility of the branch 3568699-invalidargumentexception-the-entity to hidden.

mably’s picture

Status: Postponed (maintainer needs more info) » Needs review
sokru’s picture

Status: Needs review » Reviewed & tested by the community

MR 305 works nicely!

  • mably committed cf1bcd1e on 3.x
    fix: #3568699 InvalidArgumentException: The entity object refers to a...

  • mably committed e16cfde8 on 2.0.x
    fix: #3568699 InvalidArgumentException: The entity object refers to a...
mably’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.