Problem/Motivation

The integration between any kind of fields and views live in field module. This is fine at the moment, because
it just deals with configurable fields (which is what the field module is about).

#2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency Once you switch over to also render base fields like that (for the purpose of translatability) you get test failures,
because now views like the content view depends on the field module. This also results in new dependency of the user module (which is itself required).

https://qa.drupal.org/pifr/test/935258 shows some of the errors

Proposed resolution

Move the field integration into the views module.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

+1, most def

dawehner’s picture

Status: Active » Needs review
FileSize
48.52 KB

*fingers crossed

Status: Needs review » Needs work

The last submitted patch, 2: 2399931-2.patch, failed testing.

The last submitted patch, 2: 2399931-2.patch, failed testing.

plach’s picture

Priority: Major » Critical

This is blocking a critical...

yched’s picture

nitpick, but:

+++ b/core/modules/entity_reference/entity_reference.views.inc
@@ -11,7 +11,7 @@
-  $data = field_views_field_default_views_data($field_storage);
+  $data = views_field_views_field_default_views_data($field_storage);

views_field_views_field... ;-)
Any way we could unrecurse the name a bit ?

[edit: also applies to views_field_views_field_label()]

yched’s picture

+++ b/core/modules/views/views.views.inc
@@ -165,5 +169,480 @@ function views_views_data() {
+function _views_field_views_get_entity_type_storage(FieldStorageConfigInterface $field_storage) {
+  $result = FALSE;
+  $entity_manager = \Drupal::entityManager();
+  if ($entity_manager->hasDefinition($field_storage->getTargetEntityTypeId())) {
+    $storage = $entity_manager->getStorage($field_storage->getTargetEntityTypeId());
+    $result = $storage instanceof SqlContentEntityStorage ? $storage : FALSE;
+  }
+  return $result;
+}

Also minor, but I think the current API around Entity type handlers could now let us check "does the storage class extend SqlContentEntityStorage ?" without actually instantiating the storage object ?

yched’s picture

+++ b/core/modules/views/views.views.inc
@@ -165,5 +169,480 @@ function views_views_data() {
+      $result = (array) $module_handler->invoke($field_storage->module, 'field_views_data', array($field_storage));
...
+/**
+ * Have a different filter handler for lists. This should allow to select values of the list.
+ */
+function list_field_views_data(FieldStorageConfigInterface $field_storage) {

Wow - this used to work back in the days where the "list" field types were provided by a list.module, but I don't think this is ever called in current HEAD ?

Should be options_field_views_data(), and live in options.module ?

dawehner’s picture

Status: Needs work » Needs review
FileSize
7.32 KB
48.35 KB

Wow - this used to work back in the days where the "list" field types were provided by a list.module, but I don't think this is ever called in current HEAD ?

Should be options_field_views_data(), and live in options.module ?

No, sure, things don't work at all at the moment, this is why we have a different critical for that: #2012130: Regression: Views integration for "list" field types is broken

Also minor, but I think the current API around Entity type handlers could now let us check "does the storage class extend SqlContentEntityStorage ?" without actually instantiating the storage object ?

Can we deal with anything beside moving in a different issue?

Note: This patch did not passed because of stupidy.

Status: Needs review » Needs work

The last submitted patch, 9: 2399931-9.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.21 KB
48.6 KB

Meh

dawehner’s picture

Issue tags: +Quickfix

It was supposed to be a quickfix (just move around the code and be done).

dawehner’s picture

Issue tags: +entity storage

.

yched’s picture

@dawehner : fair enough, will open a separate issue for #7.

Last remaining nitpick : can we also simplify the name of views_field_views_field_label() ?
(see #6)

dawehner’s picture

well, I kept that one, because views_field_label() sounds way too generic ... better suggestions, maybe views_entity_field_label() ?

yched’s picture

views_[...]_field_[...]_label() : yeah, mulling on that.

Meanwhile:

--- a/core/modules/views/views.views.inc
+++ b/core/modules/views/views.views.inc

+use Drupal\Core\Field\FieldConfigInterface;

+function views_field_views_field_label($entity_type, $field_name) {
+  ...
+  ... $field_definition instanceof FieldConfigInterface ...

That's the wrong FieldConfigInterface, this will also catch BaseFieldOverrides, which we don't want here.
It should be Drupal\field\FieldConfigInterface, that's what the current field_views_field_label() uses.
See #2399301: There should be only one FieldConfigInterface :-/

dawehner’s picture

FileSize
4.87 KB
48.26 KB

Reroll and rename

yched’s picture

views_entity_field_label() - why not I guess.

RTBC when #16 is fixed :-)

dawehner’s picture

FileSize
48.26 KB
539 bytes

RTBC when #16 is fixed :-)

Oh right, my brain decided today, that it a good idea to ignore you for a while :P
This is quite confusing ...

yched’s picture

Status: Needs review » Reviewed & tested by the community

;-)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1.  * @see field_views_data()
    
     * @see field_views_data_alter()
    
    field_views_field_default_views_data()
    

    all appear in views.api.php and need changing since these functions no longer exist. There are multiple instances...

  2. function list_field_views_data(FieldStorageConfigInterface $field_storage) {
    

    Isn't this function name problematic because there is hook_field_views_data? This is a separate, already existing, issue just noticed whilst reviewing.

  3. /**
     * Implements hook_hook_info().
     */
    function field_hook_info() {
      $hooks['field_views_data'] = array(
        'group' => 'views',
      );
      $hooks['field_views_data_alter'] = array(
        'group' => 'views',
      );
    
      return $hooks;
    }
    

    I think this needs to move the views module.

dawehner’s picture

Status: Needs work » Needs review
FileSize
51.09 KB
3.74 KB

Go(o)d catches!

Isn't this function name problematic because there is hook_field_views_data? This is a separate, already existing, issue just noticed whilst reviewing.

Well, this implements the existing hook, and yes, this function is broken beyond repair.

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Stuff from #21 addressed. Looks good to me.

  • webchick committed 938051c on 8.0.x
    Issue #2399931 by dawehner, yched: Generic entity api field handler...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 082b123 on 8.0.x
    Revert "Issue #2399931 by dawehner, yched: Generic entity api field...

  • webchick committed 06bed5c on 8.0.x
    Issue #2399931 by dawehner, yched: Generic entity api field handler...
penyaskito’s picture

Published change record.

jhedstrom’s picture

While working on #2395763: Fields are not 'click sortable' in views, I realized that as part of the fix here, the relevant test from the field module (Drupal\field\Tests\Views\ApiDataTest) should probably have also been moved to the views module. Should that be a separate follow-up issue?

dawehner’s picture

@jhedstrom
Yeah a follow up would be great!

jhedstrom’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.