PHP deprecation: optional parameter declared before required parameter in ConfigurableLanguageManager

Created on 20 October 2023, about 1 year ago

Problem/Motivation

my log is full of depcreation logs

Deprecated function: Optional parameter $type declared before required parameter $language is implicitly treated as a required parameter in include() (line 576 of /private/var/www/xxxx/xxxx/vendor/composer/ClassLoader.php).
include('/private/var/www/xxxx/xxxx/web/core/includes/bootstrap.inc') (Line: 576)
Composer\Autoload\{closure}('/private/var/www/xxxx/xxxx/web/core/modules/language/src/ConfigurableLanguageManager.php') (Line: 427)
Composer\Autoload\ClassLoader->loadClass('Drupal\language\ConfigurableLanguageManager') (Line: 259)
Drupal\Component\DependencyInjection\Container->createService(Array, 'language_manager') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('language_manager', 1) (Line: 440)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 237)
Drupal\Component\DependencyInjection\Container->createService(Array, 'path_alias.manager') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('path_alias.manager', 1) (Line: 440)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 237)
Drupal\Component\DependencyInjection\Container->createService(Array, 'path_alias.path_processor') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('path_alias.path_processor', 1) (Line: 440)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 273)
Drupal\Component\DependencyInjection\Container->createService(Array, 'path_processor_manager') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('path_processor_manager', 1) (Line: 440)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 237)
Drupal\Component\DependencyInjection\Container->createService(Array, 'router.route_provider') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('router.route_provider', 1) (Line: 440)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 237)
Drupal\Component\DependencyInjection\Container->createService(Array, 'options_request_listener') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('options_request_listener') (Line: 105)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

with a litte research i found out that the function setCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE, LanguageInterface $language) triggers the warning. I don't know what the procedure is in such a case: reversing the order would destroy many function calls in core & contrib, which is certainly more likely to be done with an own deprecation.
is it save to set $language = null?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Closed: works as designed

Version

10.1

Component
Language system 

Last updated about 16 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇦🇹Austria crmn

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

Comments & Activities

  • Issue created by @crmn
  • Status changed to Postponed: needs info about 1 year ago
  • There is no runtime function in Drupal 10.1 core called setCurrentLanguage. You have there a patch applied or this is referring to a contributed module.

  • Status changed to Closed: works as designed about 1 year ago
  • 🇦🇹Austria crmn

    ah, thank you! there is indeed a patch wich adds this code. I didn't even think about that

Production build 0.71.5 2024