Project Proposal: Never break links

PROJECT PICKED BY TEAM UNICORN

This project is based on https://jira.neos.io/browse/NEOS-721 and the work done by @bwaidelich (https://review.typo3.org/#/c/24873/).

Goals

As an editor, I want to be able to change a document path segment (URI), without breaking all links. Neos need to help me, by creating 301/303 to redirect old URI to the new ones (recursively) or return 410 when I remove a document.

This feature need to be flexible and decoupled from Neos (external but official package). I need to be able to configure the feature (enabled or not + http status code).

The storage of the redirection need to be based on an Interface to implement different storage strategies. The default strategies will be based on MySQL, but we are open to more performant storage like Redis (implemented by the community).

Features

  • A Flow package to provide the API and CLI interface to manage redirects
  • A Flow package to provide a default redirection storage implementation (database based)
  • A Neos adapter package to listen to workspace publishing to update the redirect automatically

Nice to have

  • A Neos package to provide a backend module to manage redirect
  • A Neos adapter package to generate redirect with a Job Queue (async), can be done by the community
5 Likes

You can follow the development of this project on github.

For the Flow parts:
https://github.com/neos/flow-development-collection/pull/195

For the Neos integration:
https://github.com/neos/neos-development-collection/pull/323

Hi Dominique,

so I installed https://github.com/neos/flow-development-collection/pull/195 today and did some testing.

Here are some problems that occured:

When I created a new redirect it showed up in redirection:list, but when i tried to call the source URI in the browser i still got a 404 error. I also ran cache:flushone Flow_Mvc_Routing_Route, but still the redirect did not occur.

Removing a redirect resulted in

The value given to remove() was Neos\RedirectHandler\Redirection , however the Neos\RedirectHandler\DatabaseStorage\Domain\Repository\RedirectionRepository can only handle Neos\RedirectHandler\DatabaseStorage\Domain\Model\Redirection instances.

  Type: TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  Code: 1298403442
  File: Packages/Framework/TYPO3.Flow/Classes/TYPO3/Flow/Persistence/Repository.php
  Line: 97

Open Data/Logs/Exceptions/20160107205630702b23.txt for a full stack trace.

Here are my ideas for features:

  • Wouldn’t it make sense for Neos to use node IDs? Otherwise we could end up in a redirect chain, when the URI changes a couple of times.
  • Make redirects manageable in a backend module
  • Make it possible to import redirects from excel files (that’s what SEO departments usually deliver after a relaunch).
  • It should be possible to set another Status Code
  • I think I already read about it somewhere but I’ll bring it up again here:
    How will we handle domains? It might be possible that the domain changes, or we maybe want to import redirects from the old page after a domain change.

Is there something like a deadline when this should be finished? I would like to help to provide code and also help with testing and gathering ideas and solutions. My current (or all time) problem is that i usually only find time to do this in the evening after work and i seldom have more than one or two hours to actually work on stuff. So the things I would take care of, could take a little longer. I could imagine that things like the backend module could be delivered afterwards or even in a seperate package.

Thanks a lot again for getting the ball rolling and making great first steps! I think all agencies working with Neos will be very thankful for this new features.

@gerhard_boden Your error during remove is solved in the last version of the PR

We can only use the URL if we wont to handle the redirect really early in the request. By storing only the ID you have the build the URL before the redirect … should be slow and too early

About the redirect chain, the code from @bwaidelich try to avoid this by updating old redirect to point to the new page. So a redirection always point to the real page, never to an other redirect.

As said earlier, it’s the plan, should be done later in a other Package, if you feel the power to start working on this backend module, go go :wink:

Community package, I plan to add bulk import / export for backup, the API could be easy to use for any kind of import / export

API wise it’s possible to return any status code, I can add settings (default: 301 and 410, but should be 303 and 404).

The last version of the PR contains a basic support for host pattern. You can have multiple domain attached to a site, the redirect will be created correctly for each domain. Multi site should be improved (clearing redirect if you move a domain from site A to site B, per ex.).

With the import/export stuff, it should be OK to import redirect for an old domain with the current API.

If you can help on the review/testing and the backend module, it’s really nice. No hurry for the backend module.

Currently my main issue is what to do if a user rename a node and the new URI match a old redirection (301) … the situation is pretty hard because of browser caching.

About this one can you run:

flow configuration:show --type Settings --path TYPO3.Flow.http.chain

You should see Neos\RedirectHandler\RedirectionComponent with position before routing

Wow this is the feature I’ve been dreaming about for ages! Will give it a spin on Monday.