Skip to content

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

Merged
mraible merged 11 commits into
roller-6.1.xfrom
absolute-url-from-config-6.1.x
Nov 20, 2026
Merged

mraible merged 11 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.

A further review pass added these fixes:

  • While the site URL is unset, adding a weblogger:<handle> planet subscription tells the administrator to set the URL first instead of failing with a 500.
  • If email activation is required and the site URL is unset, registration is refused with a message instead of creating an account that can never be activated. A failed activation email is reported on the welcome page.
  • Saving the site URL for an administrator is best-effort everywhere, so a database lock timeout can't fail the request.

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
…ring

Adding a weblogger:<handle> planet subscription while the site URL is unset now tells the administrator to set the URL first instead of failing with a NullPointerException. The background updater still skips local feeds quietly. The subscription page also shows the message of a fetcher error that has no wrapped cause, rather than "null".

When activation emails are required but can't be sent because the site URL is unset, registration is refused before the account is saved, so the username isn't taken by an account that can never be activated. The first administrator is still let through. If the activation email fails for any other reason, the welcome page shows an error instead of telling the visitor to check their email.

Saving the site URL for the first administrator's registration and on an administrator's request is now best-effort for unchecked exceptions too, such as a lock timeout, as it already is in the installer.

The concurrent site URL test restores the original value in a finally block, and the later-registrations test also asserts that compareAndSetProperty is not called.

@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 32304dd3b: The current code addresses both earlier review points. The shared fix matches #320; the additional emoticon change is specific to this branch. This was a static review, with no build run.

Earlier comments: 2 of 2 resolved.

No new issues found.

@mraible
mraible merged commit 49f5cf7 into roller-6.1.x Nov 20, 2026
7 checks passed
@mraible
mraible deleted the absolute-url-from-config-6.1.x branch November 20, 2026 00:52
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