Commit 11e22129 authored by Tim Graham's avatar Tim Graham
Browse files

Removed settings.SEND_BROKEN_LINK_EMAILS per deprecation timeline.

parent aa93a189
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -168,9 +168,6 @@ FILE_CHARSET = 'utf-8'
# Email address that error messages come from.
SERVER_EMAIL = 'root@localhost'

# Whether to send broken-link emails. Deprecated, must be removed in 1.8.
SEND_BROKEN_LINK_EMAILS = False

# Database connection info. If left empty, will default to the dummy backend.
DATABASES = {}

+0 −8
Original line number Diff line number Diff line
import hashlib
import logging
import re
import warnings

from django.conf import settings
from django.core.mail import mail_managers
from django.core import urlresolvers
from django import http
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.utils.http import urlquote
from django.utils import six
@@ -108,12 +106,6 @@ class CommonMiddleware(object):
        """
        Calculate the ETag, if needed.
        """
        if settings.SEND_BROKEN_LINK_EMAILS:
            warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. "
                "Use BrokenLinkEmailsMiddleware instead.",
                RemovedInDjango18Warning, stacklevel=2)
            BrokenLinkEmailsMiddleware().process_response(request, response)

        if settings.USE_ETAGS:
            if response.has_header('ETag'):
                etag = response['ETag']
+0 −20
Original line number Diff line number Diff line
@@ -1917,24 +1917,6 @@ available in ``request.META``.)
    If any of those are not true, you should keep this setting set to ``None``
    and find another way of determining HTTPS, perhaps via custom middleware.

.. setting:: SEND_BROKEN_LINK_EMAILS

SEND_BROKEN_LINK_EMAILS
-----------------------

.. deprecated:: 1.6
    Since :class:`~django.middleware.common.BrokenLinkEmailsMiddleware`
    was split from :class:`~django.middleware.common.CommonMiddleware`,
    this setting no longer serves a purpose.

Default: ``False``

Whether to send an email to the :setting:`MANAGERS` each time somebody visits
a Django-powered page that is 404ed with a non-empty referer (i.e., a broken
link). This is only used if ``CommonMiddleware`` is installed (see
:doc:`/topics/http/middleware`). See also :setting:`IGNORABLE_404_URLS` and
:doc:`/howto/error-reporting`.

.. setting:: SERIALIZATION_MODULES

SERIALIZATION_MODULES
@@ -2934,7 +2916,6 @@ Email
* :setting:`EMAIL_SUBJECT_PREFIX`
* :setting:`EMAIL_USE_TLS`
* :setting:`MANAGERS`
* :setting:`SEND_BROKEN_LINK_EMAILS`
* :setting:`SERVER_EMAIL`

Error reporting
@@ -2942,7 +2923,6 @@ Error reporting
* :setting:`DEFAULT_EXCEPTION_REPORTER_FILTER`
* :setting:`IGNORABLE_404_URLS`
* :setting:`MANAGERS`
* :setting:`SEND_BROKEN_LINK_EMAILS`
* :setting:`SILENCED_SYSTEM_CHECKS`

File uploads
+0 −40
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ from io import BytesIO
import random
import re
from unittest import skipIf
import warnings

from django.conf import settings
from django.core import mail
@@ -21,7 +20,6 @@ from django.middleware.transaction import TransactionMiddleware
from django.test import TransactionTestCase, TestCase, RequestFactory, override_settings
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_str
from django.utils.six.moves import xrange

@@ -241,44 +239,6 @@ class CommonMiddlewareTest(TestCase):
        self.assertEqual(r.url,
            'http://www.testserver/customurlconf/slash/')

    # Legacy tests for the 404 error reporting via email (to be removed in 1.8)

    @override_settings(IGNORABLE_404_URLS=(re.compile(r'foo'),),
                       SEND_BROKEN_LINK_EMAILS=True,
                       MANAGERS=('PHB@dilbert.com',))
    def test_404_error_reporting(self):
        request = self._get_request('regular_url/that/does/not/exist')
        request.META['HTTP_REFERER'] = '/another/url/'
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", RemovedInDjango18Warning)
            response = self.client.get(request.path)
            CommonMiddleware().process_response(request, response)
        self.assertEqual(len(mail.outbox), 1)
        self.assertIn('Broken', mail.outbox[0].subject)

    @override_settings(IGNORABLE_404_URLS=(re.compile(r'foo'),),
                       SEND_BROKEN_LINK_EMAILS=True,
                       MANAGERS=('PHB@dilbert.com',))
    def test_404_error_reporting_no_referer(self):
        request = self._get_request('regular_url/that/does/not/exist')
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", RemovedInDjango18Warning)
            response = self.client.get(request.path)
            CommonMiddleware().process_response(request, response)
        self.assertEqual(len(mail.outbox), 0)

    @override_settings(IGNORABLE_404_URLS=(re.compile(r'foo'),),
                       SEND_BROKEN_LINK_EMAILS=True,
                       MANAGERS=('PHB@dilbert.com',))
    def test_404_error_reporting_ignored_url(self):
        request = self._get_request('foo_url/that/does/not/exist/either')
        request.META['HTTP_REFERER'] = '/another/url/'
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", RemovedInDjango18Warning)
            response = self.client.get(request.path)
            CommonMiddleware().process_response(request, response)
        self.assertEqual(len(mail.outbox), 0)

    # Other tests

    def test_non_ascii_query_string_does_not_crash(self):