Fatal error on language detection and selection page (PHP8.1)

Created on 27 February 2023, over 1 year ago

Problem/Motivation

Upgrading PHP version to 8.1 produces fatal errors on language detection and selection admin form. These issues were shown as warnings on previous PHP versions. (/admin/config/regional/language/detection)

Steps to reproduce

Install core version 9.5.3 using PHP version 8.1.5

Proposed resolution

Update code to remove errors.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

9.5

Component
Language systemย  โ†’

Last updated about 20 hours ago

  • Maintained by
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @sun
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom hebl

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

Comments & Activities

  • Issue created by @hebl
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom hebl
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom hebl
  • Status changed to Postponed: needs info over 1 year ago
  • Drupal core doesnโ€™t have a shield module so the steps to reproduce cannot be accurate.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

    @cilefen I am also facing the same issue...

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States maxstarkenburg Washington, DC

    I'm reproducing this error by visiting /admin/config/regional/language/detection on a D10.0.11 (php 8.1.17) site that doesn't use shield. Here's what I'm seeing instead:

    The website encountered an unexpected error. Please try again later.
    
    TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 137 of core/modules/language/src/Form/NegotiationConfigureForm.php).
    
    Drupal\language\Form\NegotiationConfigureForm->buildForm()
    call_user_func_array() (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 692)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    

    However, I tried to reproduce on different site (9.5.11, php 8.1.24) and couldn't reproduce there (page seemed to load fine, and no dblog warnings). Haven't done a full dig into what other site differences might explain the error on the former vs. lack thereof on the latter.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cybercoda

    Status report shows "The Content Language Settings entity type needs to be installed." after upgrade from Drupal 8 to Drupal 9. Tried upgrading from Drupal 9 to Drupal 10 but still have the "The Content Language Settings entity type needs to be installed.". Went I try to visit "/admin/config/regional/language" or "/admin/config/regional/language/detection" on either site to set content language I get "The website encountered an unexpected error. Please try again later.". Watchdog shows the following error...

    TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 137 of /var/www/html/web/core/modules/language/src/Form/NegotiationConfigureForm.php)

    #0 /var/www/html/web/core/modules/language/src/Form/NegotiationConfigureForm.php(137): in_array('language_interf...', NULL)
    #1 [internal function]: Drupal\language\Form\NegotiationConfigureForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
    #2 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
    #3 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm('language_negoti...', Object(Drupal\Core\Form\FormState))
    #4 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\language\Form\NegotiationConfigureForm), Object(Drupal\Core\Form\FormState))
    #5 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
    #6 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #7 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #8 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #10 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #12 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #14 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #15 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #21 {main}

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Is this error preventing any site from upgrading to a supported version of Drupal?

    If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue โ†’ (starting from "Install Drupal core")

    If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024