Skip to content

Redirect gracefully when translation already exists - #1002

Open
bboro wants to merge 3 commits into
mainfrom
redirect-duplicate-translation
Open

Redirect gracefully when translation already exists#1002
bboro wants to merge 3 commits into
mainfrom
redirect-duplicate-translation

Conversation

@bboro

@bboro bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Apply upstream Drupal core patch d.o. #2137815 via composer.patches.json
  • The patch adds a redirect in ContentTranslationController::add() when the target translation already exists, preventing an uncaught InvalidArgumentException (WSOD)
  • Added test coverage in ServerGeneralTranslatorTest to verify the redirect behavior

Test plan

  • Access /node/[nid]/translations/add/en/[langcode] for a node that already has a translation in that language
  • Verify redirect to /node/[nid]/translations
  • Run ddev phpunit --filter testRedirectWhenTranslationAlreadyExists

🤖 Generated with Claude Code

Instead of a WSOD, redirect to the translation overview with a warning
when a user tries to add a translation that already exists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bboro
bboro requested a review from amitaibu March 11, 2026 18:22
@amitaibu

Copy link
Copy Markdown
Member

Is this a Drupal core bug? If so, can we create an MR?

@bboro

bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator Author

@amitaibu I think it comes from Core yeah. The fix in core may take months to make it in though 😅

@bboro

bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator Author

@amitaibu what would the TB be for the core fix? is ~2h good?

@amitaibu

Copy link
Copy Markdown
Member

The fix in core may take months to make it in though

Indeed. But I suspect we might already have an existing MR for this, we can't be the first ones.

is ~2h good?

Exactly. If no existing issue found (please check on a clean Drupal installation)

@bboro

bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator Author

@amitaibu if there's an MR/Patch already existing, how would you like to proceed? Patch DS for now? Or just leave it?

@amitaibu

Copy link
Copy Markdown
Member

Likely patch DS

@bboro

bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator Author

Found the core issue: https://www.drupal.org/project/drupal/issues/2137815

I'll patch DS and revert this.

bboro and others added 2 commits March 11, 2026 19:47
Apply d.o. #2137815 patch to ContentTranslationController to redirect
to the translation overview instead of throwing an exception when a
user tries to add a translation that already exists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bboro

bboro commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator Author

TB: 0.5 / 2h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants