diff --git a/CHANGES.rst b/CHANGES.rst index c107955..0b40f70 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,12 @@ Changelog 5.2.4 (unreleased) ------------------ +- Fix the issue in the @translation GET endpoint: If this + endpoint is invoked, possibly by a bot, and plone.app.multilingual + is not installed, the call will result in an empty search query + on the catalog. + [lucabel] + - backport https://github.com/plone/Products.CMFPlone/pull/3845 fix: avoid searching all users when many_users is flagged [mamico] diff --git a/src/redturtle/volto/monkey.py b/src/redturtle/volto/monkey.py index dae8073..e17dc6c 100644 --- a/src/redturtle/volto/monkey.py +++ b/src/redturtle/volto/monkey.py @@ -3,6 +3,7 @@ from plone.app.caching import purge from plone.app.event.base import dt_start_of_day from plone.app.event.recurrence import Occurrence +from plone.app.multilingual.interfaces import IPloneAppMultilingualInstalled from plone.event.interfaces import IEventAccessor from plone.event.recurrence import recurrence_sequence_ical from plone.event.utils import pydt @@ -132,3 +133,14 @@ def getPotentialMembers(self, searchString): if findAll or searchString: return self._old_getPotentialMembers(searchString) return [] + + +def plone_restapi_pam_translations_get(self, expand=False): + """If plone.app.multilingual is not installed get_restricted_translations will + search for the translations in the portal catalog with the unexisting index + TranslationsGruop. this measn that the method will iterate over the whole + catalog. We need to check if the method is available before calling it. + """ + if not IPloneAppMultilingualInstalled.providedBy(self.request): + return {"translations": {"@id": f"{self.context.absolute_url()}/@translations"}} + return self._old___call__(expand=expand) diff --git a/src/redturtle/volto/monkey.zcml b/src/redturtle/volto/monkey.zcml index 68066d7..186c176 100644 --- a/src/redturtle/volto/monkey.zcml +++ b/src/redturtle/volto/monkey.zcml @@ -42,4 +42,12 @@ preserveOriginal="True" /> + +