Skip to content

Conversation

@dkehne
Copy link
Collaborator

@dkehne dkehne commented Jan 16, 2026

Summary

Fixes the Internal Server Error that occurs when deleting a language with many translations.

Problem

When deleting a language, all translations (pages, events, POIs) with that language get cascade-deleted. For each deletion, the linkcheck library's pre_delete signal fires and calls get_absolute_url(). With thousands of translations, this causes a timeout before the DELETE query reaches the database.

Evidence

  • region_actions.py already uses disable_listeners() when deleting regions
  • The comment there states: "Active linkchecking would drastically slow performance"
  • language_tree_actions.py was missing this pattern

Solution

Wrap language_node.delete() with disable_listeners() - the same pattern already used for region deletion.

Test plan

  • Delete a language that has many translations in a test region
  • Verify no timeout or Internal Server Error occurs
  • Verify the language and all its translations are properly deleted

Fixes #3997

🤖 Generated with Claude Code

Problem:
When deleting a language, all translations (pages, events, POIs) with that
language get cascade-deleted. For each deletion, the linkcheck library's
pre_delete signal fires and calls get_absolute_url(). With thousands of
translations, this causes a timeout before the DELETE query reaches the database.

Evidence:
- region_actions.py already uses disable_listeners() when deleting regions
- The comment there states: "Active linkchecking would drastically slow performance"
- language_tree_actions.py was missing this pattern

Solution:
Wrap language_node.delete() with disable_listeners() - the same pattern
already used for region deletion.

Fixes #3997

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
# When a language is deleted, all translations (pages, events, POIs) are cascade-deleted.
# For each deletion, linkcheck's pre_delete signal calls get_absolute_url().
# With many translations, this causes a timeout before the DELETE query reaches the database.
# This pattern is also used in region_actions.py for the same reason.
Copy link
Member

@svenseeberg svenseeberg Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should be removed.

Removing linkcheck listeners disabled, the links would AFAICT not be deleted. That means we potentially keep outdated links in the database. That means we need to clean up these as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Simplified the comment.

Regarding the orphaned links: The findlinks management command will clean them up on its next run. This is the same pattern used in region_actions.py for region deletion.

The linkcheck data model separates Url (the actual URL string) from Link (the relationship to a content object). When translations are deleted:

  • Only the Link records become orphaned
  • Url records stay intact (may still be used by other regions)
  • findlinks deletes orphaned Link records and only removes Url records if no Link references them

So other regions' links are unaffected by this cleanup.

- Shortened the verbose comment as requested
- Clarified that orphaned links will be cleaned up by findlinks command
- This is consistent with the pattern used in region_actions.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dkehne dkehne requested a review from svenseeberg January 19, 2026 11:56
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.

Deleting a language causes Internal Server Error

3 participants