Skip to content

Commit

Permalink
remove lru_cache from toolbar (memory leak)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Jan 27, 2025
1 parent 4246965 commit 3d3fb81
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions djangocms_versioning/plugin_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from cms import __version__ as cms_version
from cms.plugin_rendering import ContentRenderer, StructureRenderer
from cms.utils.placeholder import rescan_placeholders_for_obj
from django.utils.functional import cached_property

from . import versionables
from .constants import DRAFT, PUBLISHED
Expand Down Expand Up @@ -50,15 +51,12 @@ def render_obj_placeholder(
):
# FIXME This is an ad-hoc solution for page-specific rendering
# code, which by default doesn't work well with versioning.
# Remove this method once the issue is fixed.
from cms.models import Placeholder

current_obj = self.toolbar.get_object()

# Not page, therefore we will use toolbar object as
# the current object and render the placeholder
rescan_placeholders_for_obj(current_obj)
placeholder = Placeholder.objects.get_for_obj(current_obj).get(slot=slot)
placeholder = rescan_placeholders_for_obj(current_obj).get(slot)

Check warning on line 59 in djangocms_versioning/plugin_rendering.py

View check run for this annotation

Codecov / codecov/patch

djangocms_versioning/plugin_rendering.py#L59

Added line #L59 was not covered by tests
content = self.render_placeholder(
placeholder,
context=context,
Expand All @@ -77,12 +75,10 @@ def render_plugin(self, instance, page=None):


class CMSToolbarVersioningMixin:
@property
@lru_cache(16)
@cached_property
def content_renderer(self):
return VersionContentRenderer(request=self.request)

@property
@lru_cache(16)
@cached_property
def structure_renderer(self):
return VersionStructureRenderer(request=self.request)

0 comments on commit 3d3fb81

Please sign in to comment.