Problem/Motivation
On #2393339: [META] Make sure Views base fields are using Field API for formatting, and do not lose functionality, we are updating all base entity fields in entity views data so that they are using Field API for formatting rather than using generic Views handlers.
This issue is about the Taxonomy module handler 'taxonomy', which is used in taxonomy_term_field_data.name
Proposed resolution
Change this field to use the Field API formatter 'field' instead of the custom formatter. Should also be able to remove the custom formatter from the code base completely.
Remaining tasks
Make a patch.
User interface changes
None.
API changes
Not really.
Comment | File | Size | Author |
---|---|---|---|
#57 | taxonomy-term-name-views-stuff-2456713.57.patch | 18.35 KB | larowlan |
#57 | interdiff.txt | 1.4 KB | larowlan |
#55 | taxonomy-term-name-views-stuff-2456713.38.patch | 18.36 KB | larowlan |
#53 | custom_taxonomy_field-2456713-53.patch | 18.36 KB | jibran |
#38 | comment-fields-2456705.24.patch | 18.1 KB | larowlan |
Comments
Comment #1
larowlanGiddyup
Comment #2
larowlanchanged definition and updated test/default views
This alters the default taxonomy view, so will need a change record for those running d8 sites.
Comment #3
larowlanand deletes the plugin
Comment #5
larowlanSchema issues
We have existing tests which use this field
Comment #7
jhodgdonAs in #2455131: Field comment_field_data.field_name should be using Field API formatter, the right fix for TaxonomyViewsData:
should actually be just to remove that first line entirely, so that the Taxonomy module doesn't override the Views default EntityViewsData (which uses the 'field' plugin for any string fields).
Then in the views configs, where they have:
you'll need to replace this with the equivalent from the generic field handler. Here's an example of how this was done in the patch for #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency when it took care of the node title fields:
Comment #8
dawehnerWe don't need this line.
... Do we link the name by default? I don't think so.
What do we do about this?
Comment #9
larowlanFixes for #7 and #8
Comment #11
larowlanwizard changes
Comment #13
larowlanschema/wizard changes
Comment #14
jhodgdonTests passed!
A few questions on the latest patch:
a) This bit of schema looks wrong (I realize it came from somewhere else, but...):
Why is a field for the term name labeled "Taxonomy Language"?!?
b) This is a bit wonky in the patch:
I think the added line should be put where the removed line was, not up with the 'tid' field?
c)
In the other views configs, there were more lines added than just changing the plugin ID, such as:
The link_to_entity setting is probably not needed, but the type: string seems like it might be?
This is also possibly a problem in:
+++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_node_term_data.yml
(two places)
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_groupwise_term_ui.yml
Other than that, looks good to me!
Comment #15
larowlanFixes #14 note that the changes in views.view.test_taxonomy_node_term_data.yml were wrong, that was an argument plugin, so reverted.
Comment #16
dawehnerI'm pretty convinced that this line doesn't have any test coverage. Nothing is adding this alias if I see that correctly in this file. If you want to the field alias of the current file, use $this->field_alias
huch, we replace the values of the name with the nid?
Comment #17
larowlanGiven point 2, I think we can say 110% there are not tests ;)
can't see myself having time for tests today, but will come back for them
Comment #18
dawehnerWe need meta tests!
Comment #19
jhodgdonPatch looks clean now, thanks! I guess all that's remaining is tests? Setting back to needs work for that.
And... side note... on the other related/similar issues, should we be removing some schema when we remove plugins? Do we need to go back to the recently-fixed issues and do that?
Comment #20
dawehnerWell, as this test clearly shows, it doens't work.
Note: $result->... is not used anymore, so the entire implementation doesn't work :)
Comment #22
larowlanDoes it work in HEAD? if not should we be splitting the convert spaces functionality into a non-critical followup?
Comment #23
dawehnerIt works in HEAD, because there the field is loaded as part of the query. Once you use the entity API field, you no longer do.
Comment #24
effulgentsia CreditAttribution: effulgentsia commentedPer #2393339-57: [META] Make sure Views base fields are using Field API for formatting, and do not lose functionality, tagging for critical office hours, but if there's a reason to not have this particular child issue in that list, please untag it.
Comment #25
dawehnerSo what you can do is to override
::getItems
, see https://www.drupal.org/files/issues/interdiff_11573.txtComment #26
larowlanwill poke at this later today
Comment #27
larowlanSo this works, but the test still fails, I think the way the display is changed doesn't stick
Any ideas?
$this->options['convert_spaces'] is always false in the test.
Comment #28
dawehnerThis should be it, feel free to upload a patch.
Comment #30
larowlanlooks ready to me, thanks @dawehner
Comment #31
dawehnerWe have to add a TaxonomyTermViewsFieldAccessTest but it should be pretty easy to do, given that the parent already does all the hard logic.
Comment #32
jibranOverall +1 for the patch.
It would be great if we could improve this in next reroll.
Comment #33
xjmDiscussed with @webchick, @effulgentsia, and @alexpott. We agreed that this issue is critical because Views should respect access restrictions for taxonomy term field content and there are common usecases for this.
Also +1 for #31; thanks @dawehner!
Comment #34
larowlanworking on test
Comment #35
larowlanAnd a test
Comment #36
jibranAwesome this is ready. Just few minor things.
Why we have this twice?
Can we please add some description explaining the use case and all that?
There is no convert_spaces setting some views export gone wrong maybe or manual edit? I think we have to re-export these views.
Shouldn't this be under settings now after this change?
Comment #37
dawehnerCan you expand the test coverage with ID, UUID and what not, please?
Comment #38
larowlanNo need for a change record here, functionality is equivalent.
Fixes #36 and #37
Re #36.4 - no its part of the plugin options, not the formatter settings.
Comment #39
jibranThanks for the fixes.
Comment #40
jibranThanks for the fixes.
Comment #41
larowlanThanks
Comment #51
larowlanDoesn't fail locally, opened #2469493: Random fails in Drupal\comment\Tests\Views\CommentUserNameTest?
Comment #52
dawehnerI have no idea why those changes landed as part of that patch ... you've uploaded the wrong patch :)
Comment #53
jibranNow with correct patch.
Comment #55
larowlanlarowlan--
Comment #57
larowlanwhoops
Comment #58
larowlanwell that was the long way round, but we're back :)
can't believe I opened a 'random test fails' issue and it turned out I'd picked the wrong file in the 'browse' window.
pebkac
Comment #59
jibranAnd 20 comments later we are back to RTBC.
Moral: Never RTBC an issue based only on interdiff. :P
Comment #60
alexpottThis issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 418497e and pushed to 8.0.x. Thanks!