Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of /app/web/core/lib/Drupal/Component/Utility/NestedArray.php)

Created on 23 July 2022, over 2 years ago
Updated 30 May 2023, almost 2 years ago

Problem/Motivation

When using exposed date group filters, if we enable "Allow multiple selections" we see an error in the logs
Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of /app/web/core/lib/Drupal/Component/Utility/NestedArray.php)

Steps to reproduce

  1. Install Drupal standard profile
  2. Edit the default Content view at /admin/structure/views/view/content
  3. Add a "Changed" filter
  4. Select "Expose this filter to visitors, to allow them to change it"
  5. Select "Grouped filters"
  6. Change the "Filter identifier" to "date"
  7. Set the Grouping 1 label to "Last week", operator to "Is greater than", value type to "An offset from ..." and value "-7 days"
  8. Check Allow multiple selections
  9. Press Apply and then Save
  10. Navigate to /admin/content
  11. Check the recent log entries

Proposed resolution

Remaining tasks

🐛 Bug report
Status

Active

Version

10.0

Component
Views 

Last updated about 17 hours ago

Created by

🇮🇳India ameymudras

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.

  • 🇨🇦Canada iStryker

    We had a similar problem. It has to do with Step #8. Allow multiple selections and exposed filters
    We had an expose filter on a taxonomy term.

    • With multiple selection unchecked the query string looks like /event?type=25 (with taxonomy term 25 selected).
    • We later change the expose filter to multiple selections. Going to the view page and selecting term 25, the query string looks like this /event?type%5B25%5D=25.
    • With it still selected with multiple sections and you visit /event?type=25 you get this error. So any old URL now throw an error.
  • Status changed to Active almost 2 years ago
  • 🇨🇦Canada iStryker

    So multiple section changes the query string from a value to an array. In my last comment type%5B25%5D=25 actually equals type[25]=25. If you have 2 values selected its type[25]=25&type[26]=26. So the problem is Drupal is looking for an array but finds a single value instead, and throws an error.

  • 🇬🇧United Kingdom kiwimind

    Just to throw some more into the mix.

    I'm building a pretty standard site at the moment and have exposed a node add form to anonymous users that then throws this error when they create a node. So seemingly nothing to do with Views or a multiple filter, so could it be something else?

    I tried adding the patch from https://www.drupal.org/project/drupal/issues/3023924 🐛 Cannot create references to/from string offsets Needs work , and while this did allow the submission to go through without the site-breaking error, it did not appear to allow the submitting values through, as it came back saying that all of the required fields needed to be filled out.

Production build 0.71.5 2024