Skip to content

Redirect wiki pages on renaming them

Himanshu Kapoor requested to merge 257892-wiki-redirections into master

What does this MR do and why?

Redirect wiki pages on renaming them

  • When you rename a wiki page now, a redirection table is created to map the old path to the new path, so all existing links will work.
  • When you create a new wiki page, or rename, the redirection table entry for the new path is removed.

Changelog: added

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Case

.gitlab/.redirects.yml file

Screenshot

When the page is redirected to another page that exists. Route: PageA -> PageB

Steps:

  1. Create a page with title PageA.
  2. Rename to PageB.
  3. Visit /-/wikis/PageA.

Expectation:

  1. You are redirected to PageB with a message saying The page at "PageA" has been moved to "PageB".
  2. .gitlab/.redirects.yml is updated to include PageA: PageB entry.
---
PageA: PageB

image.png

When the page is redirected to another page that exists. Route: PageA -> PageB -> PageC -> PageD

Steps:

  1. Create a page with title PageA.
  2. Rename to PageB.
  3. Rename to PageC.
  4. Rename to PageD.
  5. Visit /-/wikis/PageA, /-/wikis/PageB, /-/wikis/PageC.

Expectation:

  1. Each of the pages PageA, PageB and PageC now redirect to PageD.
  2. Three entries are added to .gitlab/.redirects.yml. See column 2.
---
PageA: PageB
PageB: PageC
PageC: PageD

image.png

When the page is redirected to another page that does not exist.

Steps:

  1. Create a page with title PageA.
  2. Rename to PageB.
  3. Delete page PageB.
  4. Visit /-/wikis/PageA.

Expectation:

  1. .gitlab/.redirects.yml still has an entry PageA: PageB. We do not delete entries on page deletion because there could be many pages pointing to that page.
  2. PageA redirects to /-/wikis/PageB, but since that page does not exist, it will show creation flow for that page.
---
PageA: PageB

image.png

When a redirection loop is hit, or a redirection limit of 50 is reached. PageA -> PageB -> PageA.

Steps:

  1. It is not possible to create redirect loops in the wiki UI, so checkout the wiki repository and edit .gitlab/.redirects.yml file and enter the contents of column 2. Commit and push.
  2. In the wiki, go to /-/wikis/PageA.

Expectation:

Going to PageA will hit a redirect loop and shows creation flow for PageA.

The reason we show editing for PageA instead of PageB here is because we don't know where the loop ends. We just show the editing for the starting page as an opportunity to break out of the loop.

---
PageA: PageB
PageB: PageA

image.png

How to set up and validate locally

Steps included in the screenshot section.

Related to #257892 (closed)

Edited by Himanshu Kapoor

Merge request reports