Skip to content

fix(redirects): honor legacy go.php doc links on the static site - #5137

Merged
phil-davis merged 1 commit into
masterfrom
fix/go-php-redirects
Jul 24, 2026
Merged

fix(redirects): honor legacy go.php doc links on the static site#5137
phil-davis merged 1 commit into
masterfrom
fix/go-php-redirects

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Member

What

ownCloud core builds documentation deep links via OC_Defaults::buildDocLinkToKey() as https://doc.owncloud.com/server/<version>/go.php?to=<key>. On the old Sphinx site go.php was a server-side PHP script that 302-redirected each key to the real page. The docs now build as a static Antora site on GitHub Pages, which runs no PHP and ignores the query string, so every go.php?to= URL 404s. Every already-deployed ownCloud server keeps emitting these links, so the fix must live on the site.

This ports owncloud-docs-monorepo PR #35 to the production owncloud/docs playbook. It ships a client-side redirector as Antora supplemental files layered on the remote docs-ui bundle — nothing in owncloud/docs-ui changes.

How

  • supplemental/js/go-redirect.js — maps each go.php key to its page under the version root, remaps unpublished version segments (the concrete current stable like 10.16, or old releases) to /server/latest/, and falls back to the version-root entrypoint for unknown/missing keys. It runs in <head> on every page and is a no-op unless the path ends in go.php, so it redirects before the 404 body paints (no visible flash).
  • supplemental/partials/head-scripts.hbs — overrides the bundle partial to load the redirector. Overriding a stock partial wholesale drops its contents, so this reproduces the bundle's Matomo block and the uiRootPath global, then adds the redirector <script>.
  • site.yml — enables the supplemental overlay (supplemental_files: supplemental).
  • test/go-redirect.test.js + npm test + CI step — unit-tests the mapping logic and, on the built site, guards against version drift (PUBLISHED_VERSIONS must equal public/server/*) and page moves (every mapped target must exist under public/server/latest).

Adaptations from PR #35

  • Domain-root paths (/server/latest/…), not the monorepo's repo path prefix — the redirector logic is prefix-agnostic and needed no change.
  • PUBLISHED_VERSIONS = ['10.15', 'next', 'latest'] — the segments this playbook actually emits (10.16 is served at /server/latest/ via latest_version_segment_strategy: replace; master at /server/next/).
  • Test infra added (this repo had none): node --test wired into CI after the build step so the guards run against public/.

Testing

  • npm test — 15 tests pass (the two build-dependent guards t.skip when public/ is absent).
  • npm run antora && npm test — full build; guards confirm public/server/* = 10.15, latest, next and every mapped target exists under public/server/latest.
  • Local smoke: /server/latest/go.php?to=admin-sharing…/admin_manual/configuration/files/file_sharing_configuration.html; unknown key → …/index.html; /server/10.16/go.php?to=user-webdav/server/latest/classic_ui/files/access_webdav.html.

Out of scope

  • The owncloud/core buildDocLinkToKey() change (Part B).
  • Any change to owncloud/docs-ui.

🤖 Generated with Claude Code

ownCloud core builds documentation deep links via
OC_Defaults::buildDocLinkToKey() as
https://doc.owncloud.com/server/<version>/go.php?to=<key>. On the old
Sphinx site go.php was a server-side PHP script that 302-redirected each
key to the real page. The docs now build as a static Antora site on
GitHub Pages, which runs no PHP and ignores the query string, so every
go.php?to= URL 404s. Every already-deployed server keeps emitting these
links, so the fix must live on the site.

Add a client-side redirector shipped as Antora supplemental files layered
on the remote docs-ui bundle:

- supplemental/js/go-redirect.js: maps each go.php key to its page under
  the version root, remaps unpublished version segments (e.g. the concrete
  10.16 current stable, or old releases) to /server/latest/, and falls
  back to the version-root entrypoint for unknown/missing keys. Runs in
  <head> and is a no-op unless the path ends in go.php, so it redirects
  before the 404 body paints.
- supplemental/partials/head-scripts.hbs: overrides the bundle partial to
  load the redirector. Reproduces the bundle's Matomo block and the
  uiRootPath global (overriding the partial wholesale would otherwise drop
  them).
- site.yml: enable the supplemental overlay (supplemental_files).
- test/go-redirect.test.js + npm test + CI step: unit-test the mapping
  logic and guard against version drift and page moves by asserting, on
  the built site, that PUBLISHED_VERSIONS matches public/server/* and every
  mapped target exists under public/server/latest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 requested a review from a team as a code owner July 24, 2026 09:34
@phil-davis
phil-davis merged commit 256ffe8 into master Jul 24, 2026
2 checks passed
@phil-davis
phil-davis deleted the fix/go-php-redirects branch July 24, 2026 10:35
@phil-davis

Copy link
Copy Markdown
Contributor

Fixed owncloud/firstrunwizard#202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants