Anonymous committed 1178ec2

Fixed #10793 -- Stopped caching paginator instances in sitemap classes to prevent stale sitemaps. Thanks, gnosek, krzysiumed and adam_przybyla.

Comments (0)

Files changed (2)


         return obj.get_absolute_url()
     def _get_paginator(self):
-        if not hasattr(self, "_paginator"):
-            self._paginator = paginator.Paginator(self.items(), self.limit)
-        return self._paginator
+        return paginator.Paginator(self.items(), self.limit)
     paginator = property(_get_paginator)
     def get_urls(self, page=1, site=None, protocol=None):


 This attribute was confusingly named ``HttpRequest.raw_post_data``, but it
 actually provided the body of the HTTP request. It's been renamed to
 ``HttpRequest.body``, and ``HttpRequest.raw_post_data`` has been deprecated.
+``django.contrib.sitemaps`` bugfix with potential performance implications
+In previous versions the Paginator objects used in sitemap classes were
+cached and could result in stale sitemap indexes. Removing this cache causes
+new Paginator objects to be created and the
+:attr:`~django.contrib.sitemaps.Sitemap.items()` method of the
+:class:`~django.contrib.sitemaps.Sitemap` subclass to be called during every
+sitemap-related request.
+If the :attr:`django.contrib.sitemaps.Sitemap.items()` method returns a
+``QuerySet`` its length will be evaluated which may lead to extra database
+queries. To mitigate the performance impact consider using the :doc:`caching
+framework </topics/cache>`.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.