"Error: Call to a member function getLanguages() on null" - when creating a redirect - no translations being used on the site...

Created on 28 October 2025, 14 days ago

Problem/Motivation

When creating a redirect we're getting this error in watchdog.

Error: Call to a member function getLanguages() on null in Drupal\redirect\Form\RedirectForm->form() (line 83 of /app/web/modules/contrib/redirect/src/Form/RedirectForm.php).

Which is the detail for the human error, "You are attempting to redirect the page to itself. This will result in an infinite loop."

This is an old site, that I inherited, so I don't know ALL of this history, but we are NOT translating content. But the LANGUAGE module is installed.

I've done all the checks I can find to see if the source path we're trying to use, exists, and it does not. I've even looked at the database in a raw text editor searching for the path... and its not there.

The code, mentioned in the error...

    // Only add the configured languages and a single key for all languages.
    if (isset($form['language']['widget'][0]['value'])) {
      foreach ($this->languageManager->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $langcode => $language) {    // <-- this is line 83, mentioned in the error
        $form['language']['widget'][0]['value']['#options'][$langcode] = $language->getName();
      }
      $form['language']['widget'][0]['value']['#options'][LanguageInterface::LANGCODE_NOT_SPECIFIED] = $this->t('- All languages -');
    }

Clearly is checking for a language setting of some kind, and I'm thinking that just having the language module installed (even though we're not using it) is causing a problem?

The language widget on the redirect is set to ALL LANGUAGES, and also gives the error if I set it to "English".
There are no other languages available on the site.

This client uses the redirect functionality WIDELY with this not being reported before (~20,000 nodes on this site, and 6159 rows in the redirect table in the DB...).

My ONLY guess, is that this being a very old node, in the 10,000 nid range, that maybe the language selection functionality was more complex, with other languages in the past... (before I took over the support of the site).... BUT, I also deleted ALL 173 revisions on this node... in my testing.

Thoughts?

Thanks.

πŸ› Bug report
Status

Active

Version

1.12

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States alphex Atlanta, GA USA

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024