Problem/Motivation

My web site shows the following error message instead of a block:
The website encountered an unexpected error. Try again later.

The system log has got this message:
Error: Call to undefined method Drupal\Core\Asset\LibraryDiscoveryCollector::getLibraryByName() in Drupal\lang_dropdown\Plugin\Block\LanguageDropdownBlock->build() (line 704 of /opt/local/www/ddd/modules/lang_dropdown/src/Plugin/Block/LanguageDropdownBlock.php)

#0 /opt/local/www/ddd/core/modules/block/src/BlockViewBuilder.php(171): Drupal\lang_dropdown\Plugin\Block\LanguageDropdownBlock->build()
#1 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#2 /opt/local/www/ddd/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array()
#3 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(886): Drupal\Core\Render\Renderer->doTrustedCallback()
#4 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Render\Renderer->doCallback()
#5 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
#6 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render()
#7 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(637): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#8 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(164): Drupal\Core\Render\Renderer->executeInRenderContext()
#9 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(191): Drupal\Core\Render\Renderer->renderInIsolation()
#10 /opt/local/www/ddd/core/lib/Drupal/Core/Render/Renderer.php(228): Drupal\Core\Render\Renderer->doRenderPlaceholder()
#11 /opt/local/www/ddd/core/modules/big_pipe/src/Render/BigPipe.php(697): Drupal\Core\Render\Renderer->renderPlaceholder()
#12 /opt/local/www/ddd/core/modules/big_pipe/src/Render/BigPipe.php(524): Drupal\big_pipe\Render\BigPipe->renderPlaceholder()
#13 [internal function]: Drupal\big_pipe\Render\BigPipe->Drupal\big_pipe\Render\{closure}()
#14 /opt/local/www/ddd/core/modules/big_pipe/src/Render/BigPipe.php(531): Fiber->start()
#15 /opt/local/www/ddd/core/modules/big_pipe/src/Render/BigPipe.php(283): Drupal\big_pipe\Render\BigPipe->sendPlaceholders()
#16 /opt/local/www/ddd/core/modules/big_pipe/src/Render/BigPipeResponse.php(113): Drupal\big_pipe\Render\BigPipe->sendContent()
#17 /opt/local/www/ddd/vendor/symfony/http-foundation/Response.php(423): Drupal\big_pipe\Render\BigPipeResponse->sendContent()
#18 /opt/local/www/ddd/index.php(20): Symfony\Component\HttpFoundation\Response->send()
#19 {main}

Steps to reproduce

Install the module version 2.3 on Drupal 10.5.1 and try to use it.

Proposed resolution

Remaining tasks

  • ✅ File an issue
  • ➖ Addition/Change/Update/Fix
  • ➖ Merge request, Patch, or Commit
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ddd200 created an issue. See original summary.

markdc’s picture

I just installed the module, and I cannot even place a block in the Block layout interface.

Language Switcher Dropdown 2.3
Drupal 10.5.2
PHP 8.3.24

Browser console

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/block/add/language_dropdown_block%3Alanguage_interface/witebord?region=menu
StatusText: error
ResponseText: The website encountered an unexpected error. Try again later.Error: Call to undefined method Drupal\Core\Asset\LibraryDiscoveryCollector::getLibraryByName() in Drupal\lang_dropdown\Plugin\Block\LanguageDropdownBlock->blockForm() (line 257 of modules/contrib/lang_dropdown/src/Plugin/Block/LanguageDropdownBlock.php). Drupal\Core\Block\BlockBase->traitBuildConfigurationForm() (Line: 35)
Drupal\Core\Block\BlockBase->buildConfigurationForm() (Line: 143)
Drupal\block\BlockForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm() (Line: 27)
Drupal\block\Controller\BlockAddController->blockAddConfigureForm()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 263)
Drupal\shield\ShieldMiddleware->bypass() (Line: 219)
Drupal\shield\ShieldMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

	(anonymous function) (ajax.js:1219)
	complete (ajax.js:608)
	c (jquery.min.js:2:25310)
	fireWith (jquery.min.js:2:26055)
	l (jquery.min.js:2:77919)
	(anonymous function) (jquery.min.js:2:80267)

Drupal log

#0 /var/project/web/core/lib/Drupal/Core/Block/BlockPluginTrait.php(188): Drupal\lang_dropdown\Plugin\Block\LanguageDropdownBlock->blockForm()
#1 /var/project/web/core/lib/Drupal/Core/Block/BlockBase.php(35): Drupal\Core\Block\BlockBase->traitBuildConfigurationForm()
#2 /var/project/web/core/modules/block/src/BlockForm.php(143): Drupal\Core\Block\BlockBase->buildConfigurationForm()
#3 /var/project/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\block\BlockForm->form()
#4 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
#5 /var/project/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
#6 /var/project/web/core/lib/Drupal/Core/Form/FormBuilder.php(284): Drupal\Core\Form\FormBuilder->retrieveForm()
#7 /var/project/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
#8 /var/project/web/core/modules/block/src/Controller/BlockAddController.php(27): Drupal\Core\Entity\EntityFormBuilder->getForm()
#9 [internal function]: Drupal\block\Controller\BlockAddController->blockAddConfigureForm()
#10 /var/project/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#11 /var/project/web/core/lib/Drupal/Core/Render/Renderer.php(637): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/project/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#13 /var/project/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#14 /var/project/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/project/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#16 /var/project/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#17 /var/project/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#18 /var/project/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#19 /var/project/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#20 /var/project/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#21 /var/project/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#22 /var/project/web/modules/contrib/shield/src/ShieldMiddleware.php(263): Drupal\page_cache\StackMiddleware\PageCache->handle()
#23 /var/project/web/modules/contrib/shield/src/ShieldMiddleware.php(219): Drupal\shield\ShieldMiddleware->bypass()
#24 /var/project/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle()
#25 /var/project/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#26 /var/project/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#27 /var/project/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#28 /var/project/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#29 /var/project/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#30 {main}
kala4ek’s picture

Assigned: Unassigned » kala4ek
Status: Active » Needs work

vinodhini.e made their first commit to this issue’s fork.

vinodhini.e’s picture

Hi, Tested this module on Drupal 10.5.1.

Encountered the same error: Call to undefined method Drupal\Core\Asset\LibraryDiscoveryCollector::getLibraryByName().

Due to this, the Language Dropdown block could not be placed.

Issue occurs immediately after enabling the module and attempting to add the block.

  • kala4ek committed 6d8f9091 on 8.x-2.x
    Issue #3539639 by ddd200, markdc, kala4ek: The module doesn't work
    
kala4ek’s picture

Version: 8.x-2.3 » 8.x-2.x-dev
Assigned: kala4ek » Unassigned
Status: Needs work » Fixed

It was broken for 10.x in #3431537: Automated Drupal 11 compatibility fixes for lang_dropdown. Now added a small wrapper to support 10.x and 11.x cores.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.