From f960753d743d77233802da800ad0f55f569f640c Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Tue, 29 Nov 2016 11:10:12 +0100 Subject: [PATCH] Add the `alters_data` attribute on `Page.copy()`. This makes sure the variable can't be printed in the template, performing an accidental copy of the page. That also happened when using the `{% print %}` tag from my django-debugtools package --- CHANGELOG.txt | 1 + docs/releases/1.8.rst | 1 + wagtail/wagtailcore/models.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index fabc4cf77..ecd9d8b06 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -33,6 +33,7 @@ Changelog * Fix: `search_garbage_collect` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert) * Fix: `wagtail.contrib.settings` context processor no longer fails when `request.site` is unavailable (Diederik van der Boor) * Fix: `TableBlock` content is now indexed for search (Morgan Aubert) + * Fix: `Page.copy()` is now marked as `alters_data`, to prevent template code from triggering it (Diederik van der Boor) 1.7 (20.10.2016) diff --git a/docs/releases/1.8.rst b/docs/releases/1.8.rst index 6a276fb71..9228a8f50 100644 --- a/docs/releases/1.8.rst +++ b/docs/releases/1.8.rst @@ -64,6 +64,7 @@ Bug fixes * ``search_garbage_collect`` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert) * ``wagtail.contrib.settings`` context processor no longer fails when ``request.site`` is unavailable (Diederik van der Boor) * ``TableBlock`` content is now indexed for search (Morgan Aubert) + * Fix: ``Page.copy()`` is now marked as ``alters_data``, to prevent template code from triggering it (Diederik van der Boor) Upgrade considerations diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index d0ba4894e..4cef026b7 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -1182,6 +1182,8 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable return page_copy + copy.alters_data = True + def permissions_for_user(self, user): """ Return a PagePermissionsTester object defining what actions the user can perform on this page