Problem/Motivation
If I attempt to install this module on a site running Group 3.x (in my case, specifically 3.0.0) certain admin pages, which are modified by Configuration Views, no longer load and instead throw the following error: "The website encountered an unexpected error. Please try again later."
Steps to reproduce
- Set up a new Drupal 10 site and install / configure the group module (3.x branch)
- Visit /admin/content (a view) and note the page loads fine
- Visit /admin/structure/types (not currently a view) and note the page loads fine
- Now install Configuration Views
- Visit /admin/content (a view) and note the page still loads fine
- Visit /admin/structure/types (NOW A VIEW) and note the page will not load
- You should see the message "The website encountered an unexpected error. Please try again later."
- The issue starts on line 372 in the group_views_query_alter function in group.module
More Details
For views provided by Drupal core, Line 372 sets the $view->build_info['query'] item properly. But for views provided by the Configuration Views module this line does nothing. The $view->build_info['query'] item remains an empty string. As a result, line 376 sets $query to an empty string for these views provided by the Configuration Views module. As a result, line 378 (where we attempt to call $query->addMetaData) fails.
Proposed resolution
Unsure how to fix. I'm not sure if the group module is making an assumption about the structure of the provided $view and $query parameters that isn't always true or if the new views provided by Configuration Views are not properly formatted.
Remaining tasks
Determine if the group code needs an update or if the Configuration Views module needs to alter the data structure for their views.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Related Issue (Group)
Issue fork config_views-3358929
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
Comment #2
monaw commentedI am having a very similar problem with Drupal 9.5.2, Group 3.0.1....
Comment #3
swirtComment #6
msielskiLooking into this I saw that
config_views/src/Plugin/views/query/ConfigEntityQuery::builddoes not contain a few lines of code whichviews/src/Plugin/views/query/Sql::buildcontains. This missing code sets$view->build_info['query']which is what was missing whengroup_views_query_alterruns. With the change in the linked MR, the reported issue seems to be fixed and can no longer be reproduced.Comment #7
msielskiComment #8
anruetherThank you for the MR, @msielski! It works for me,
/admin/structure/typesis available again.edit: I use config_views in conjunction with content_model_documentation
Comment #9
mortona2k commentedI'm using this with content_model_documentation and group, and this fixes the error on admin pages for me.
It's a small change, explained well by the developer's comments above.
Comment #10
ultimikeThis MR worked for me as well with Drupal core 10.3.9, Group module 3.3.0, and version 2.1.1 of this module.
-mike
Comment #11
scott_euser commentedIf I understand this right, the issue comes when pagination is involved? Is that correct? Ie, not necessarily specific to Group module. Just want to consider how we can add test coverage for this.
Comment #12
scott_euser commentedAlso looks like #3177042: Error: group_views_query_alter() Call to a member function addMetaData() takes a different approach to the same problem?
Comment #16
scott_euser commentedGranting credit from related issue.
Comment #17
scott_euser commentedMoving back to needs review for advice on #11 so I can understand how to add test coverage.
Comment #18
scott_euser commentedOkay reproduced, added test coverage that fails without this (essentially mimicking what Group does)
Thanks all!