Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Products.isurlinportal directly #4000

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions Products/CMFPlone/URLTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from Products.CMFCore.URLTool import URLTool as BaseTool
from Products.CMFPlone.patches.gtbn import rewrap_in_request_container
from Products.CMFPlone.PloneBaseTool import PloneBaseTool
from Products.isurlinportal import isURLInPortal
from zope.component import getUtility


Expand All @@ -14,26 +15,10 @@ class URLTool(PloneBaseTool, BaseTool):
security = ClassSecurityInfo()
toolicon = "skins/plone_images/link_icon.png"

@security.public
mauritsvanrees marked this conversation as resolved.
Show resolved Hide resolved
def isURLInPortal(self, url, context=None):
# Note: no docstring, because the method is publicly available
# but does not need to be callable on site-url/portal_url/isURLInPortal.
#
# This method is overridden by Products.isurlinportal,
# but the public declaration still seems needed.
#
# Also, in tests/testURLTool.py we do not use layers,
# which means the Products code is not loaded,
# so we need to import it explicitly.
# This is done once.
try:
from Products.isurlinportal import isURLInPortal
except ImportError:
# If this somehow fails, it seems better to have a safe fallback,
# instead of a hard failure.
return False

return isURLInPortal(self, url, context=context)
# The implementation of this method was moved to Products.isurlinportal
# to be able to more quickly do a security release in case there is a
# problem in this part.
isURLInPortal = isURLInPortal

def getPortalObject(self):
portal = aq_parent(aq_inner(self))
Expand Down
3 changes: 3 additions & 0 deletions news/12.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Use `Products.isurlinportal` directly, instead of relying on it patching our `URLTool`.
This solves a cyclic dependency.
[maurits]