Since plone 4.3.12, the <base href attribute in HTML generated by Plone no longer always points to the context URL as it used to prior to the change. This change broke Plone and some add-ons. More breakage may still surface. Fixes have varied because no alternative was provided when the change was made.
For a lengthy background, see the discussion.
Rather than rolling back the change which was done to support some other things and would require reverting them, I suggest providing a future-proof alternative (thanks @rodfersou for suggesting using a new attribute):
Plone 5 has removed <base href completely. Instead Plone 5 has added a data-base-url attribute to the HTML body tag. Which points to the context URL.
So, I suggest same be done for Plone 4. That way, anything in Plone core and/or add-ons needing context URL in Javascript have a future-proof way of getting it from here on.
I did some pull requests to fix this and other issues related:
https://github.com/plone/Products.CMFPlone/pull/2101/files
https://github.com/zopefoundation/Products.CMFDefault/pull/1/files
https://github.com/plone/plonetheme.sunburst/pull/17/files
https://github.com/plone/plonetheme.classic/pull/6/files
Applied code review suggestions at all pull requests.
New Jenkins job: http://jenkins.plone.org/job/pull-request-4.3/26/console
To test you can use a custom buildout configuration like this:
[buildout]
extends =
buildout.cfg
auto-checkout +=
Products.CMFPlone
Products.CMFDefault
plonetheme.sunburst
plonetheme.classic
[sources]
Products.CMFPlone = git ${remotes:plone}/Products.CMFPlone.git pushurl=${remotes:plone_push}/Products.CMFPlone.git branch=issue_2051
Products.CMFDefault = git git://github.com/rodfersou/Products.CMFDefault.git pushurl=${remotes:zope_push}/Products.CMFDefault.git branch=issue_2051
plonetheme.sunburst = git ${remotes:plone}/plonetheme.sunburst.git pushurl=${remotes:plone_push}/plonetheme.sunburst.git branch=issue_2051
plonetheme.classic = git ${remotes:plone}/plonetheme.classic.git pushurl=${remotes:plone_push}/plonetheme.classic.git branch=issue_2051
and run buildout like this:
$ ./bin/buildout -c custom.cfg
Fix tests.
New Jenkins Job: http://jenkins.plone.org/job/pull-request-4.3/28/console
green o/
Wait.. there is a better way to write the fallback without guess the context url, I'll refactor now
Didn't work my idea.. I tried to add a new variable in jsvariables point into context url, but at time @@jsvariables is executed, the context is the Plone site object, no luck here.
@plone/framework-team can someone help me please with this last idea?
@pgrunewald @mauritsvanrees do you have any idea on a way to fix the context of @@jsvariables view to point to the current object? currently it points to the root object.
If this works I can add a new javascript variable with the context, avoiding the need to guess the context url at my polyfill.
Is it safe to use HTTP_REFERER request.environ variable?
I'll use it now.. need someone to validate it for me (please)
New Jenkinks Job: http://jenkins.plone.org/job/pull-request-4.3/29/console
@petri all merged o/
Most helpful comment
@petri all merged o/