Make Redirects fieldable

Created on 7 August 2018, over 6 years ago
Updated 14 March 2023, over 1 year ago

I would prefer that redirects were field-able so that I could add a taxonomy or other type of field to organize and manage redirects. I would add a taxonomy field to identify redirects used for ad campaigns, changes to paths, paths from old sites, etc.

✨ Feature request
Status

Needs review

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States dgwebcreative Reno, NV

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France federiko_

    I applied patch from comment #6 but had no luck. When editing a redirection, an error message appeared stating :

    Notice : Undefined index: #value dans locale_form_redirect_edit_form_alter() (/app/web/modules/contrib/redirect/redirect.module ligne 261)

    Exception: Object of type Drupal\Core\Language\Language cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 454 of /app/web/core/lib/Drupal/Core/Template/TwigExtension.php)

    Environnment = drupal 9.4.10 + PHP 7.4

  • πŸ‡«πŸ‡·France federiko_

    In my case, in a fresh drupal 9.4.10 installtion, removing the locale_form_redirect_edit_form_alter() function is solving the issue I had.

  • Status changed to Needs work over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    That must not be removed but fixed if it changed, maybe you configured the field to be hidden or so?

  • πŸ‡«πŸ‡·France federiko_

    I have performed a fresh installation and added a text field through the UI on the redirection module.

    I decided to remove the 'locale_form_redirect_edit_form_alter()' hook because it seems to not be used at all, at least in recent drupal core versions. But you're right @Berdir it's possible that doing so could affect compatibility with older versions of Drupal 8 or 9. I will investigate this further.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    It has nothing to do with the drupal core version and yes it is definitely used or you would not have received an error.

    If you have a single-language site then you likely don't see it, but it's there and used.

  • πŸ‡«πŸ‡·France federiko_

    I have received an error related to the code added in comment #5, which has not been commited yet if I am not wrong...

    The code added disables the bundle support for redirect entity and had as a consequence to change the redirect entity edit form id and also trigger locale_form_redirect_edit_form_alter()... (which mas not triggered before , if I understand well)
    Before that, the form alter was never triggered because it was targeting an old form id (redirect_edit_form and not redirect_redirect_edit_form).
    But may be I am missing something...

    The language field related code seems to be implemented there, at least in Drupal 9.2+ :
    https://git.drupalcode.org/project/redirect/-/blob/8.x-1.x/src/Entity/Re...

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    You're right, the logic of that hook was moved to \Drupal\redirect\Form\RedirectForm::form(), it can indeed be removed.

    I expected that this also needs an update function, but it's currently not reporting anything on the status page, possibly because the key was bogus and never actually used.

  • πŸ‡«πŸ‡·France federiko_

    So to sum up :
    - it seems that locale_form_redirect_edit_form_alter() is deprecated code, which removal does not have any impact at all.
    - as a consequence of disabling bundle support for the redirect entity and to avoid collision with updated/patched redirect edit form id, it seems also that we could remove this deprecated code

    Then the remaining question that I see for a generic implementation is : can the modification of the redirect edit form id have an impact outside of the redirect module ? If a custom module (named my_custom_module) implemented my_custom_module_form_redirect_redirect_edit_form_alter() that custom hook would stop working, is that correct ?

  • πŸ‡·πŸ‡ΊRussia kala4ek πŸ‡·πŸ‡Ί Novosibirsk

    Looks like locale_form_redirect_edit_form_alter() was already removed during some other ticket and patch from #8 not applied anymore. So here is updated patch.

Production build 0.71.5 2024