- π«π·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 10:19am 15 March 2023 - π¨π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 7:26am 16 March 2023 - π¨π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 thatlocale_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 codeThen 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.