Skip to content

Take the site URL from setup or an administrator, not from the first request - #337

Open
mraible wants to merge 10 commits into
roller-6.1.xfrom
absolute-url-from-config-6.1.x
Open

mraible wants to merge 10 commits into
roller-6.1.xfrom
absolute-url-from-config-6.1.x

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The 6.1.x version of #320, including its per-host cache keys and the save from an administrator's request.

  • InitFilter no longer keeps the first request's URL as the site URL for the whole application. Each request's URL is available on its own thread for that request, and getAbsoluteContextURL() falls back to it only while site.absoluteurl is unset, logging a warning once. A request reads the setting once, so its links and cache keys agree even if an administrator sets the URL meanwhile.
  • While it's unset, the page, feed, site-wide and planet caches include the request's URL in their keys, so content built for one host name is only served to requests for that host name, and caching keeps working. Content rendered outside a request isn't cached, the cache warmup job waits, and the rendering caches are cleared when the URL is first saved.
  • The installer's bootstrap step, the first administrator's registration, and the first Roller UI request from a global administrator save site.absoluteurl when it's still unset and the host looks like a public name, using compareAndSetProperty() so only the first save is kept. On an upgraded 6.1.x site, which runs no installer step, the first admin page view fills it in. Local and private addresses, and host names without a dot such as localhost, are left for an administrator to set under Server Admin > Configuration, which the log and error messages point to.
  • While it's unset, comment and approval notifications go out without links, activation and invitation emails aren't sent and the caller is told why, the pending entry notice logs a warning, and the planet sync task and local feed fetcher skip their work.
  • Request URLs keep the request's scheme and port, so HTTPS sites get https:// links.

For 6.1.8 specifically: the ping queue runs outside any request, so pings are skipped (with a warning) until site.absoluteurl is set. The emoticon plugin built its image tags once, with the URL of whichever request loaded it first; it now adds the current request's site URL when rendering, or the context path outside a request. WebloggerRuntimeConfig.setAbsoluteContextURL and InitFilter.getAbsoluteUrl are removed. CHANGES (#336) tells admins to set "Absolute URL to site".

Changes from master: Install implements ServletRequestAware here, as on master, and the tests use javax.servlet.

Tests: InitFilterTest, InstallTest, RegisterSiteUrlTest, SiteUrlForAdminTest, SiteUrlWhileUnsetTest, MailUtilSiteUrlTest, PlanetSiteUrlTest, SmileysPluginSiteUrlTest and new PropertiesTest cases. mvn test passes, and the Selenium integration tests pass. The master version was measured on a copy of a production site: no difference between the setting set and empty.

When site.absoluteurl is empty, the installer's bootstrap step and the registration of the first administrator now save it from that request (scheme, host, port and context path). InitFilter no longer stores a request-derived absolute URL for the whole application. Instead it makes each request's URL available on its own thread for the length of that request, and getAbsoluteContextURL() falls back to it only while site.absoluteurl is unset, logging a warning once.

Page, feed, site-wide and planet output that used the request's URL is not added to the rendering caches. The request URL now uses the request's scheme and keeps non-default ports, so HTTPS sites get https:// links.

Install now receives the servlet request through ServletRequestAware, as Register already does, and its bootstrap checks use it in place of ServletActionContext.

(cherry picked from commit 8032cff)
… admin's request

While site.absoluteurl is unset, the page, feed, site-wide and planet caches now include the request's absolute URL in their keys instead of skipping the cache, so content built with one host name is only served to requests for that host name and caching keeps working. The first Roller UI request from a global administrator saves site.absoluteurl when it's still unset, which fills it in on sites upgraded without it.

@snoopdave snoopdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 538e832d1: The fix is consistent with #320; the differences are explained by the 6.1.x servlet and Struts APIs. I found two gaps in the behavior while the site URL is unset.

… only once

A request now reads site.absoluteurl once, the first time it builds a link or a cache key, so its links and the key its content is cached under always agree even if an administrator sets the URL meanwhile. Content rendered outside a request isn't cached while the URL is unset, the cache warmup job skips its work until then, and the rendering caches are cleared when the URL is first saved.

Saving the URL from setup or an administrator's request now uses compareAndSetProperty(), so when several requests try at once only the first one's URL is kept. Planet links also go through getAbsoluteContextURL() instead of reading the property directly.
While site.absoluteurl is unset, comment and approval notifications are still sent but leave out their links, since the only URL available is the host name of the request that caused them. Activation, invitation and pending entry emails exist to deliver a link, so they aren't sent: activation and invitation report why to the caller, and the pending entry notice logs a warning.
The planet sync task and the local feed fetcher store absolute links to each weblog. Until site.absoluteurl is set they can't build those links, so they skip their work instead of storing incomplete URLs.
The installer, the first administrator's registration and the first administrator request only save their URL as site.absoluteurl when its host looks like a public name. Loopback and private addresses, and host names without a dot such as localhost or a proxy's backend name, are left for an administrator to set under Server Administration > Configuration.
SmileysPlugin built its img tags once, with the URL of whichever request first loaded it, and reused them for every later request. It now keeps only the path and adds the current request's site URL when rendering, or the relative context path outside a request.
The log and error messages about an unset site URL now point to Server Admin > Configuration, matching the tab labels.
The planet sync task and local feed fetcher now wait for site.absoluteurl, so the test sets it, as a configured site would, and clears it afterwards.
@mraible

mraible commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

A second review raised a few more points, now addressed in the latest commits:

  • Same changes as Take the site URL from setup, not from the first request #320 for emails, planet tasks, local hosts and the cache bound. On this branch SmileysPlugin also built its img tags once with the first request's URL; it now adds the site URL when rendering (falling back to the relative context path outside a request), and SmileysPluginSiteUrlTest renders for two hosts in turn.

@mraible
mraible requested a review from snoopdave November 18, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants