Cannot create references to/from string offsets

Created on 4 January 2019, over 6 years ago
Updated 14 July 2023, over 1 year ago

Summary:

Generically, the issue seems to be no graceful failure when form builder expects an array and gets a string.

Steps to Reproduce:

  • Create a view.
  • Add a filter (e.g. a taxonomy with filter identifier "tid"), make it exposed; configure the filter to "Allow multiple selections"
  • Make a page display (e.g. "/test_view") to allow easy access to the filter query params. Save and navigate to the page.
  • Use the exposed filter and note that the URL becomes something like "test_view?tid[N]=N" where N is the id of your taxonomy term.
  • Change the query parameter to be something like "?tid=foo".
    Note that you get a fatal error ""

This error is identical to that mentioned in , summarized here:

When Layout builder is active and I try to save a Content type "The website encountered an unexpected error. Please try again later." turns up and I have the below errors. What could this be?
PHP 7.2.13-1+0~20181207100540.13+stretch~1.gbpf57305
DB 5.5.5-10.1.37-MariaDB-0+deb9u1
Error: Cannot create references to/from string offsets i Drupal\Component\Utility\NestedArray::setValue() (rad 155 av /web/core/lib/Drupal/Component/Utility/NestedArray.php)... [rest of stack trace omitted]

Note that the patches offered below (with the exception of the debug patch) are essentially identical and differ only in the line number in core/lib/Drupal/Core/Form/FormBuilder.php where the change is applied.

The patch has worked for me (D9.5.9, PHP8.1) with custom views - again, with a different line number.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Formย  โ†’

Last updated about 3 hours ago

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance hassebasse

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024