TypeError: Argument 1 passed to Drupal\Component\Utility\UrlHelper::buildQuery() must be of the type array, string given, called in /core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php on line 154 in Drupal\Component\Utility\UrlHelper::buildQuery()

Created on 21 April 2018, over 6 years ago
Updated 2 July 2023, over 1 year ago

After updating the drupal core to drupal 8.5.2, an error occurred every time I navigated to

admin/structure/menu/manage/primary-links?destination=/admin/structure/menu

, The error was :

ypeError: Argument 1 passed to Drupal\Component\Utility\UrlHelper::buildQuery() must be of the type array, string given, called in /core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php on line 154 in Drupal\Component\Utility\UrlHelper::buildQuery()

this is the code implemented in line 154 of UnroutedUrlAssembler.php :
$query = $options['query'] ? ('?' . UrlHelper::buildQuery($options['query'])) : '';

I changed the code to :
$query = $options['query'] && is_array($options['query']) ? ('?' . UrlHelper::buildQuery($options['query'])) : '';

And the error is gone.

🐛 Bug report
Status

Closed: cannot reproduce

Version

9.5

Component
Base 

Last updated 3 days ago

Created by

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

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    Wonder if this is still an issue? Tried replicating by editing a menu and menu link (url in the IS) but couldn't replicate.

    If still an issue we may want to track down what exactly is causing this.

  • Status changed to Closed: cannot reproduce over 1 year ago
  • 🇳🇿New Zealand quietone

    More information was asked for 5 months ago and none has been supplied. Before that, there was no discussion on the root cause, that is, why $options is not an array. Adding the check may simply be hiding a problem and then we don't know if that problem is in custom, contrib or core.

    Since we don't have that information I am closing this 5 year old issue.

    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").

    Thanks!

Production build 0.71.5 2024