Problem/Motivation

There is a warning message where views are loaded. I was not able to find the origin of this but I'm guessing this could be related to Quicktabs (alpha5).

Warning: Illegal string offset 'value' in Drupal\views\Plugin\views\filter\NumericFilter->valueForm() (line 256 of core/modules/views/src/Plugin/views/filter/NumericFilter.php).

Steps to reproduce

* Create a view of content items
* Enable aggregation
* For the default filter criteria "Content: Published = "Yes", under aggregation settings, change "Group results together" to any of the aggregation operators. Note this is not usually something you would want to do, but the UI does let you do it. You will get an an AJAX error, and the dialog box that pops up won't close, so you'll need to manually close the dialog box.
* Try saving the view
* At this point you'll be in an unrecoverable WSOD any time you try to edit the view, because the `adminSummary` for that status field will throw the error cited here. It's particularly annoying because there's no way to actually fix the error that I've found short of deleting the view and re-creating it. I had to patch my code locally just in order to get back to the View edit interface and change the aggregation settings back to a working value.

Proposed resolution

Created a patch with a solution that verified if the variable is set or not.

Remaining tasks

Tests

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

Issue fork drupal-3244956

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

alexis_saransig created an issue. See original summary.

afsch’s picture

StatusFileSize
new1000 bytes
cilefen’s picture

Category: Task » Bug report
Status: Active » Postponed (maintainer needs more info)
Issue tags: -views +Needs steps to reproduce

We'll need steps to reproduce and failing automated test to reveal a bug in core. Also Drupal 8 is end of life in two weeks.

cilefen’s picture

Issue tags: +Bug Smash Initiative

Please get a stack trace too.

afsch’s picture

StatusFileSize
new1020 bytes

Updating the temporal patch.

lendude’s picture

@alexis_saransig as @cilefen pointed out, could you provide some steps to reproduce this with just Drupal core? Usually these kinds of errors come from badly setup code elsewhere (as you pointed out in de issue summary this could be related to Quicktabs) and we don't want to hide these warnings because they are doing their job, warning against bad code.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

t_stallmann’s picture

I ran into this issue but in a different line of code in the module. Steps to reproduce are as follows:
* Create a view of content items
* Enable aggregation
* For the default filter criteria "Content: Published = "Yes", under aggregation settings, change "Group results together" to any of the aggregation operators. Note this is not usually something you would want to do, but the UI does let you do it. You will get an an AJAX error, and the dialog box that pops up won't close, so you'll need to manually close the dialog box.
* Try saving the view
* At this point you'll be in an unrecoverable WSOD any time you try to edit the view, because the `adminSummary` for that status field will throw the error cited here. It's particularly annoying because there's no way to actually fix the error that I've found short of deleting the view and re-creating it. I had to patch my code locally just in order to get back to the View edit interface and change the aggregation settings back to a working value.

t_stallmann’s picture

StatusFileSize
new693 bytes
cilefen’s picture

Status: Postponed (maintainer needs more info) » Needs review

It would be great if the steps to reproduce were in the issue summary.

ameymudras’s picture

Issue summary: View changes
ameymudras’s picture

Version: 9.4.x-dev » 9.5.x-dev
StatusFileSize
new832 bytes
new776 bytes

Tested the above patch with Drupal 9.5 and php 8 and I was still facing an issue:


TypeError: Cannot access offset of type string on string in Drupal\views\Plugin\views\filter\NumericFilter->adminSummary() (line 394 of /app/web/core/modules/views/src/Plugin/views/filter/NumericFilter.php)

I have made changes to the patch to fix the issue

Status: Needs review » Needs work

The last submitted patch, 15: 3244956-15.patch, failed testing. View results

narendra.rajwar27’s picture

Status: Needs work » Needs review
StatusFileSize
new789 bytes

Trying to fix failed test cases.

lendude’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

We still need some steps to reproduce in the IS please.
Edit: Oops completely scanned over them! Thanks for adding those!

Also we need an automated test for this, since we are changing logic and the patch in #17 is doing something different than the patch in #12 which was preventing the fatal error apparently.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

didebru’s picture

StatusFileSize
new3.18 KB

I've faced that issue when I create an exposed filter for a boolean field with any as default.

didebru’s picture

StatusFileSize
new3.18 KB

Reroll for 9.4.x

didebru’s picture

Status: Needs work » Needs review
didebru’s picture

StatusFileSize
new476 bytes

Test only.

didebru’s picture

StatusFileSize
new3.64 KB
didebru’s picture

StatusFileSize
new781 bytes
new3.94 KB

Status: Needs review » Needs work

The last submitted patch, 25: 3244956-9.4.x-with-test-25.patch, failed testing. View results

didebru’s picture

StatusFileSize
new781 bytes
new3.94 KB
didebru’s picture

la558’s picture

I'm facing this problem as well; unfortunately, none of the above patches worked for me.
Drupal: 9.5.9
PHP: 8.1.17
MySQL: 8.0.30

TypeError: Cannot access offset of type string on string in Drupal\views\Plugin\views\filter\NumericFilter->adminSummary() 
(line 396 of /web/core/modules/views/src/Plugin/views/filter/NumericFilter.php)

However, I edited patch 17 adjusting the line numbers and it worked

diff --git a/core/modules/views/src/Plugin/views/filter/NumericFilter.php b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
index 30556125ab..5f9c99d973 100644
--- a/core/modules/views/src/Plugin/views/filter/NumericFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -392,7 +392,7 @@ public function adminSummary() {
     if (in_array($this->operator, $this->operatorValues(2))) {
       $output .= ' ' . $this->t('@min and @max', ['@min' => $this->value['min'], '@max' => $this->value['max']]);
     }
-    elseif (in_array($this->operator, $this->operatorValues(1))) {
+    elseif (in_array($this->operator, $this->operatorValues(1)) && isset($this->value['value'])) {
       $output .= ' ' . $this->value['value'];
     }
     return $output;

Thanks!

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pfrenssen’s picture

@La558, your proposed line change is already included in the patch from #27, it is recommended to try testing the latest patch first, rather than going back to older revisions of the patch.

@DiDebru, thanks for adding some test coverage! It seems to need some more work though, since the test-only version of the patch is supposed to have a failure indicating the bug.

liquidcms’s picture

I was trying to make a view of a simple bundle that had a multivalue field and use aggregation to count (field) the number of items and filter on counts being > X. When i added count filter the view crashed. I get a WSOD with:

TypeError: Cannot access offset of type string on string in Drupal\views\Plugin\views\filter\NumericFilter->adminSummary() (line 413 of E:\www\dev\web\core\modules\views\src\Plugin\views\filter\NumericFilter.php).

when i try to add it and from the point on my view is corrupt. Adding this patch allows me to edit the view again.

Sadly, i am still not able to filter on count.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.