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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Title: Field plugin for "Field API" fields still refers to 'storage_details' » Views "group by" on "Field API" fields broken
Status: Active » Needs review
FileSize
1.31 KB

Patch.

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 ?

yched’s picture

Uploading 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" (?).

dawehner’s picture

Issue tags: +Needs tests

Just 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.

yched’s picture

As @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 :-/

dawehner’s picture

Sure 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 :)

yched’s picture

LOL - yes, way past naptime indeed :-)

yched’s picture

swentel’s picture

Note sure if this is related, by process_entity() also has following code:

      foreach ($this->group_fields as $field_name => $column) {
        if (property_exists($values, $this->aliases[$column])) {
          $base_value[$field_name] = $values->{$this->aliases[$column]};
          if (isset($base_value[$field_name])) {
            $data = TRUE;
          }
        }
      }

$values doesn't even exist within the scope

swentel’s picture

swentel’s picture

Issue summary: View changes

Issue link

jibran’s picture

Status: Needs review » Needs work

The last submitted patch, 7: field_views_storage_details-2081533_7.patch, failed testing.

dawehner’s picture

Priority: Normal » Critical
Issue summary: View changes

Given that people rely on this feature I consider this as a critical.

catch’s picture

Priority: Critical » Major

Critical 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.

dawehner’s picture

So we need to ensure that we test the following scenarious:

  • count by NID, groupby field
  • groupby field A, count field B

Here is something like a start for a test.

heddn’s picture

Issue summary: View changes
Issue tags: +Needs manual testing, +Novice
epersonae2’s picture

I'm trying out the proposed scenarios. Will report back shortly.

epersonae2’s picture

Issue summary: View changes
FileSize
64.59 KB

Grouping 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.

epersonae2’s picture

Issue summary: View changes
epersonae2’s picture

FileSize
65.06 KB

Tested scenario 2: Group by Content: Relationship (a text list field), Count Title. Looks like it works fine. See screenshot.

andriyun’s picture

Issue tags: -Needs manual testing

Manual test added. So... Lets remove proper tag.

geertvd’s picture

Assigned: Unassigned » geertvd
Issue tags: -Novice +DUGBE0609

I think the novice part of this issue was the manual testing, so removing that tag.
I'm working on automated tests now.

geertvd’s picture

Status: Needs work » Closed (fixed)

so 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).