Allow redirects to be 'disabled'

Created on 1 March 2024, 4 months ago
Updated 4 March 2024, 4 months ago

Problem/Motivation

Redirect in Drupal 7 had the concept of a 'disabled' redirect. This was a redirect that was in the database, stored, but wouldn't actually cause any redirects to be performed.

This was somewhat useful for users where content would be, for example, periodically available. Someone could go and disable a redirect, and the content was available and then enable the redirect if they wanted to make the content 'unavailable' in some sense.
While this certainly wasn't perfect, it was a useful feature.
Creating a redirect from scratch each time introduces the potential for errors and mistakes, like setting the wrong response code etc.

I note that several people want this: https://www.drupal.org/project/redirect/issues/3164712#comment-14019435 πŸ› Don't migrate disabled redirects Active

Steps to reproduce

Use the D8+ version of the module.

Proposed resolution

This is possibly a can of worms, but I suspect that adding a new base field for 'status' would be enough and the threading this through the various places that need it.

Remaining tasks

User interface changes

This is going to add status or enabled/disabled in lots of places.

API changes

This is likely to need a few API additions in some methods.

It might be worth going to the next major version, to make it clear that something is fundamentally changing.

Data model changes

A new base field on the redirect entity.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Steven Jones

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Steven Jones
  • πŸ‡¬πŸ‡§United Kingdom Steven Jones
  • πŸ‡¬πŸ‡§United Kingdom Steven Jones

    I've started work in the MR on this.

    Things remaining:

    • Have an upgrade path that doesn't assume that the redirect entities are in the database.
    • Get tests passing (I've not touched them, I assume that they will break with these changes.)
    • Add some more tests for enabled/disabled redirects.
    • If the status column was in Drupal 6 redirect, add the migration code for that.
    • See if the submodules need any changes.
    • Consider changing the signature of \Drupal\redirect\RedirectRepository::findMatchingRedirect to accept an ENUM so that one could query for only disable redirects.
  • Status changed to Needs review 4 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 4 months ago
    63 pass
  • πŸ‡¬πŸ‡§United Kingdom Steven Jones

    Uploading a patch to get the tests tested. I've not added any new tests for this functionality yet.

Production build 0.69.0 2024