Fix custom menu link translations on insert, update, and when deleted

Created on 3 May 2022, over 2 years ago
Updated 4 October 2023, about 1 year ago

Problem/Motivation

Custom menu link translation deletion leads to error
InvalidArgumentException: The entity object refers to a removed translation (fi) and cannot be manipulated. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of /var/www/drupal/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Steps to reproduce

  1. enable the Admin Audit Trail Menu module and all of the core translation modules
  2. add second language and enable custom menu link translation
  3. translate custom menu link to additional language
  4. delete custom menu link translation

Proposed resolution

Switch to use the following hooks

  • hook_menu_link_insert
  • hook_menu_link_update
  • hook_menu_link_delete

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ✅ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release notes snippet
  • ✅ Release admin_audit_trail-1.0.2

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇮Finland mikran

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024