Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php:
$rkey = $this->definition['is revision'] ? 'FIELD_LOAD_REVISION' : 'FIELD_LOAD_CURRENT';
// Go through the list and determine the actual column name from field api.
foreach ($options as $column) {
$name = $column;
if (isset($this->field_info['storage_details']['sql'][$rkey][$this->table][$column])) {
$name = $this->field_info['storage_details']['sql'][$rkey][$this->table][$column];
}
}
Original report:
I'm not sure what this code does, but this is most likely broken, 'storage_details' doesn't exist anymore after #1497374: Switch from Field-based storage to Entity-based storage
Proposed resolution
Remaining tasks
For now, ignore the patches on this issue and see if it is still a problem. There is no longer any mention of 'storage_details', as was originally reported. Test the following scenarios :
- count by NID, groupby field
- groupby field A, count field B
If this is no longer a problem, the issue can be safely closed out as not able to reproduce.
User interface changes
n/a
API changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#19 | views-group-scenario2.png | 65.06 KB | epersonae2 |
#17 | views-group-scenario1.png | 64.59 KB | epersonae2 |
#14 | 2081533-test-start-do-not-expect-anything-at-all.patch | 1.38 KB | dawehner |
#7 | field_views_storage_details-2081533_7.patch | 1.38 KB | yched |
#4 | views.view_.test_field_group_by.yml_.txt | 5.07 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedPatch.
What is weird though is that I can't reproduce an actual fail here.
- I set up a view that uses "group by" on a Field API field
("Format" section, click "settings"; in the "Style options" popup, select the field in "Grouping field Nr.1")
- The view works as expected in both HEAD & patch
That's because \Drupal\field\Plugin\views\field\Field::query() is always called with param $use_groupby == FALSE, so the code fixed here doesn't run anyway - yet the view works, results are grouped by values of the field.
What am I missing here ? Am I using the wrong views setup to test $use_groupby ?
Comment #2
yched CreditAttribution: yched commentedUploading the test view I'm using - groups on node "body" field.
Field name should be views.view.test_field_group_by.yml, obviously - d.o renamed it "for security reasons" (?).
Comment #3
dawehnerJust in general we should add test coverage for it, so something like /core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php but for fieldapi fields.
Comment #4
yched CreditAttribution: yched commentedAs @dawehner pointed in IRC, I was looking at the wrong place in Views UI to set up aggregation.
This view generates a broken query in HEAD, and runs fine with the patch.
Although honestly, writing a test similar to QueryGroupByTest is a little bit beyond me right now :-/
Comment #5
dawehnerSure sure, I just wanted to give myself some hints tomorrow, as it is so late that I won't remember everything. Maybe you should also consider to take a nap :)
Comment #6
yched CreditAttribution: yched commentedLOL - yes, way past naptime indeed :-)
Comment #7
yched CreditAttribution: yched commentedReroll after #2079011: Move field.module constants related to storage to EntityStorageControllerInterface
Comment #8
swentel CreditAttribution: swentel commentedNote sure if this is related, by process_entity() also has following code:
$values doesn't even exist within the scope
Comment #9
swentel CreditAttribution: swentel commentednote, also mentioned in #1866260: Undefined variable in Field:process_entity()
Comment #9.0
swentel CreditAttribution: swentel commentedIssue link
Comment #10
jibran7: field_views_storage_details-2081533_7.patch queued for re-testing.
Comment #12
dawehnerGiven that people rely on this feature I consider this as a critical.
Comment #13
catchCritical is data loss/fatal errors/systemic bugs, this is self-contained and doesn't harm anything else, but agreed on major rather than normal at least.
Comment #14
dawehnerSo we need to ensure that we test the following scenarious:
Here is something like a start for a test.
Comment #15
heddnComment #16
epersonae2 CreditAttribution: epersonae2 commentedI'm trying out the proposed scenarios. Will report back shortly.
Comment #17
epersonae2 CreditAttribution: epersonae2 commentedGrouping under Format works fine, but these scenarios sound more like Aggregation (under Advanced).
Scenario 1: Count NID, Group Results Together by Value on Title (Group column: Value) works with two nodes with the same title. See attached screenshot.
Going to test scenario 2 momentarily.
Comment #18
epersonae2 CreditAttribution: epersonae2 commentedComment #19
epersonae2 CreditAttribution: epersonae2 commentedTested scenario 2: Group by Content: Relationship (a text list field), Count Title. Looks like it works fine. See screenshot.
Comment #20
andriyun CreditAttribution: andriyun commentedManual test added. So... Lets remove proper tag.
Comment #21
geertvd CreditAttribution: geertvd at XIO commentedI think the novice part of this issue was the manual testing, so removing that tag.
I'm working on automated tests now.
Comment #22
geertvd CreditAttribution: geertvd at XIO commentedso this is not actually broken in HEAD anymore.
The code referenced in the IS is not there anymore, and I'm seeing some test coverage for this in
\Drupal\views\Tests\QueryGroupByTest
and\Drupal\views_ui\Tests\GroupByTest
So i think this can be closed since this has been fixed elsewhere (probably #2407801: Views generic field handler does not work with base fields).