Opened 9 years ago

Closed 8 years ago

#1859 closed defect (invalid)

Flat page URLs send broken-link emails when SEND_BROKEN_LINK_EMAILS set to true

Reported by: Matt Owned by: adrian
Component: Contrib apps Version: master
Severity: normal Keywords: SEND_BROKEN_LINK_EMAILS flat page flatpage flatpages
Cc: treborhudson@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When SEND_BROKEN_LINK_EMAILS is set to true in a project's settings file, an email is sent to site managers even when a flat page is retreived.

Change History (7)

comment:1 Changed 9 years ago by ubernostrum

I wonder if this isn't dependent on the order of middleware classes; do you still see this if you have FlatpageFallbackMiddleware listed before CommonMiddleware (since in that case the flatpage middleware should catch the request and prevent a 404 from being raise before CommonMiddleware sends the email)?

comment:2 Changed 9 years ago by Matt

I have FlatpageFallbackMiddleware listed above all other middleware classes (purely by accident I think), so order doesn't seem to affect this. My middleware classes are ordered as follows:

MIDDLEWARE_CLASSES = (
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.doc.XViewMiddleware',
    'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
)

comment:3 Changed 8 years ago by Rob Hudson <treborhudson@…>

  • Cc treborhudson@… added

comment:4 Changed 8 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

Sounds like a bug to me.

comment:5 Changed 8 years ago by Marc Fargas <telenieko@…>

This ticket was opened one year ago, could somebody confirm it? I've looked at the code and there's no reason why FlatPages should be returning a 404 to the next middleware.

comment:6 Changed 8 years ago by orestis@…

  • Component changed from Core framework to Contrib apps

I've seen this too, it does happen when the flatpages middleware is at the top of the list.

The docs specify that the flatpage middleware should be last, as it is a last resort. However, elsewhere, it is noted that the response middleware is evaluated in reverse order. So I think this is what makes this confusing. If you put the flatpage middleware last on the list, it's response function is processed first and CommonMiddleware isn't run.

I think the flatpage docs should be changed to tell you that the flatpage middleware should be placed *AFTER* the CommonMiddleware, in order to prevent this from happening.

So, for the OP: Move the flatpages middleware after CommonMiddleware.

comment:7 Changed 8 years ago by Simon G. <dev@…>

  • Resolution set to invalid
  • Status changed from new to closed

Ok, I'm closing this as invalid as it appears to be a docs issue w.r.t middleware ordering and not the flatpages app.

Note: See TracTickets for help on using tickets.
Back to Top