Use Url::fromRouteMatch instead of Url::fromRoute

Created on 15 March 2023, over 1 year ago
Updated 17 March 2023, over 1 year ago

Just installed Drupal 9.5.5 and got the following when viewing frontend page containing the block:

TypeError : count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 238 of /public_html/web/modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php )
#0 /public_html/web/modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php(238): count()
#1 /public_html/web/core/modules/block/src/BlockViewBuilder.php(171): Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build()
#2 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#3 /public_html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#4 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#5 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#6 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#7 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(160): Drupal\Core\Render\Renderer->render()
#8 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{ closing}()
#9 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(161): Drupal\Core\Render\Renderer->executeInRenderContext()
#10 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(175): Drupal\Core\Render\Renderer->renderPlain()
#11 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(665): Drupal\Core\Render\Renderer->renderPlaceholder()
#12 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(550): Drupal\Core\Render\Renderer->replacePlaceholders()
#13 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#14 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(148): Drupal\Core\Render\Renderer->render()
#15 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{ closing}()
#16 /public_html/web/core/lib/Drupal/Core/Render/Renderer.php(149): Drupal\Core\Render\Renderer->executeInRenderContext()
#17 /public_html/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(279): Drupal\Core\Render\Renderer->renderRoot()
#18 /public_html/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(128): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders()
#19 /public_html/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()
#20 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond()
#21 /public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#22 /public_html/vendor/symfony/http-kernel/HttpKernel.php(202): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#23 /public_html/vendor/symfony/http-kernel/HttpKernel.php(190): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#24 /public_html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#25 /public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#26 /public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#27 /public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#28 /public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
#29 /public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
#30 /public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#31 /public_html/web/modules/contrib/raven/src/StackMiddleware/RavenMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#32 /public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\raven\StackMiddleware\RavenMiddleware->handle()
#33 /public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#34 /public_html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#35 /public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#36 {main}

Reverting to Drupal 9.5.4 solved.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kruser

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

Comments & Activities

  • Issue created by @kruser
  • πŸ‡ΊπŸ‡ΈUnited States kmonty San Francisco, CA

    I'm currently working on a patch based off the work done here: https://www.drupal.org/project/language_switcher_menu/issues/3348242 πŸ› SA-CORE-2023-003 Fixed

  • Assigned to kmonty
  • πŸ‡ΊπŸ‡ΈUnited States kmonty San Francisco, CA

    I have a patch working on localdev. Going to have our QA team give it a test before posting here. Assigning to myself for now.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States kmonty San Francisco, CA

    Our team is satisfied that this is sufficient to get us to be able to deploy the security release. I didn't look into if this needs tests or anything. Again, just prioritized getting today's security release out. Hope this helps folks!

    Note: patch was written against `3.0.x-dev` but it applies cleanly to `3.1.0`

  • πŸ‡«πŸ‡·France tostinni

    I can confirm that this patch also fixed these errors that we had after testing 9.5.5 which was breaking the language switcher.

    - Notice: Trying to get property 'links' of non-object in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 147 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).
    - Warning: Invalid argument supplied for foreach() in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 186 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).
    - Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 238 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).
    
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Confirming this issue. Just killed a project with a WSOD ;)

    Maintainer should have a look asap.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Aligned the title to be more clear. The fix might be correct, but someone has to test this carefully. I can't do this currently.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • I can confirm that the patch in #4 fixes this issue.

  • @anybody opened merge request.
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Created a MR from #4

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @SKAUGHT or @Grevil could you please review this? LGTM!

    Should also be cherry-picked into 4.0.x once merged.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I was now able to reproduce the reported issues and can confirm it's perfectly fixed by this patch. Also I think πŸ’¬ Dropbutton disappear Closed: duplicate had the same reason.

    Thanks @kmonty for fixing this! I'll now merge the fix into 3.0.x and 4.0.x

  • Status changed to RTBC over 1 year ago
    • Anybody β†’ committed 6ccb97fe on 3.0.x
      Issue #3348286: Use Url::fromRouteMatch instead of Url::fromRoute
      
    • Anybody β†’ committed faa5e5ab on 4.0.x
      Issue #3348286: Use Url::fromRouteMatch instead of Url::fromRoute
      
  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Merged into 3.0.x and cherry-picked into 4.0.x!

    Thank you very much! I don't have permission to administer releases, so @SKAUGHT will have to create a 3.1.4 and 4.0.3 release to fix this in stable releases.

    Thank you all! :)

  • Thank you for being this responsive! I had the exact same problem. I will wait until the stable release to update our instances :)

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

Production build 0.71.5 2024