#19099: Broken link email sent on redirect by i18n_patterns -------------------------------------+------------------------------------- Reporter: aaugustin | Owner: aaugustin Type: Bug | Status: new Component: | Version: master Internationalization | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by aaugustin): After some more tests, here's what I've found. Currently, [https://github.com/django/django/blob/0775ab295566ccb306b8ae6340d2690c3d0aa6af/docs/topics/i18n/translation.txt#L1391 the documentation] says that `LocaleMiddleware` should come before `CommonMiddleware`. It means that during response processing, `CommonMiddleware.process_response` runs first, and it sends the broken link email before `LocaleMiddleware.process_response` gets a chance to redirect to the expected URL. (That's very similar to #1859.) Putting `CommonMiddleware` before `LocaleMiddleware` solves the problem with broken link emails, but creates other bugs; notably, missing trailing slashes aren't appended to URLs when the prefix is a non-default language. These results can be reproduced easily with: - a URLconf with `i18n_patterns`, such as the following: {{{ urlpatterns = i18n_patterns('views', url(r'^contact/$', 'contact'), ) }}} - `APPEND_SLASH = True` - `LANGUAGE_CODE = 'en'` - `LANGUAGES = (('en', _('English')), ('fr', _('French')))` So, in the current state of things, `i18n_patterns` and `SEND_BROKEN_LINK_EMAILS` are incompatible. ---- The best solution I can think of is to move the broken link emails feature to its own middleware, say, `BrokenLinksMiddleware`, that should come before `LocaleMiddleware`. Besides, 404 errors reporting by email sounds a bit archaic these days; does it really belong in `CommonMiddleware`? It's a bit difficult to create a clean deprecation path for this change. I think `CommonMiddleware.process_response` could raise warnings if `SEND_BROKEN_LINK_EMAILS` is `True` but `BrokenLinksMiddleware` isn't in `MIDDLEWARE_CLASSES`. In this case, during the deprecation period, it would call `BrokenLinksMiddleware.process_response`. -- Ticket URL: <https://code.djangoproject.com/ticket/19099#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.