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
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 comment_field_data.field_name field, which is currently using the 'standard' Views handler.
Proposed resolution
Change comment_field_data.field_name to use the Field API formatter 'field' instead of 'standard'.
Remaining tasks
Make a patch.
User interface changes
None.
API changes
Not really.
Comment | File | Size | Author |
---|---|---|---|
#19 | 2455131-comment-field-name-views-19.patch | 9.48 KB | andypost |
#19 | interdiff.txt | 807 bytes | andypost |
#17 | 2455131-comment-field-name-views-17.patch | 9.48 KB | andypost |
#17 | interdiff.txt | 1.41 KB | andypost |
Comments
Comment #1
jhodgdonAs per parent issue, this issue needs to be elevated to Critical. The base entity fields using Views formatters currently need to be updated to use Entity-aware field formatters instead, to respect entity access.
Comment #2
larowlanding ding
Comment #3
larowlanComment #4
jhodgdonWow, that was fast! Even with a test, which even passes. Thanks! I can't see anything wrong with this simple patch.
I also checked all of the core-provided views configs that listed comment_field_data as the base table in Views, and none of them were using the 'field_name' field. (I guess that might exclude ones with relationships, but that seems like a long shot.) That probably explains why you decided it was a good idea to create such a test view and a test.
Anyway, thanks! I think this is ready to go.
Comment #5
andypostare we sure there's no more usage?
Suppose to be removed
Comment #6
larowlanfixes #5
Comment #7
dawehnerMeh, can't we avoid adding web tests
You should be able to get rid of the entire code block. Also 'field_name' here is afaik not needed. ... The entire field should be autogenerated
Comment #8
jhodgdonGuess I was too quick to RTBC. I woke up this morning realizing the entire override of the 'field' section for this should be removed too.
RE #5, I did check that there is no usage of this field in any configured views. It shouldn't be too commonly used -- this is the field that says "What is the name of the comment field this comment is from?" I'm actually not sure why we even have views integration for it, but whatever.
Comment #9
larowlanFixes #7.2
For 7.1 do you have an example you could point me at?
Note this is Drupal\comment\Tests\View\CommentTestBase not Drupal\comment\Tests\CommentTestBase, but yeah still eventually winds back to WebTestBase via ViewsTestBase.
Comment #10
dawehnerWell, there is ViewUnitTestBase you can use
Comment #11
andypostThe issue probably holds #2456705: Comment views field handlers need to be replaced with field/entity aware handlers
Comment #12
andypost@dawehner we can't use
ViewUnitTestBase
because we need comment module installed.I found no way to test render of the field because
$view->field
is emptyComment #13
dawehnerYou could use assertIdenticalResultSet here.
Comment #14
andyposthere it is
Comment #15
jhodgdonLooks good to me (but I'm shy about RTBC because of earlier). Thanks!
Comment #16
dawehnerThis looks alright now.
Comment #17
andypostDiscussed with @dawehner at IRC and discovered that better to extend a test with render to check access, so extended the test
Comment #18
xjmComment #19
andypostThe right service to use is account switcher
Comment #20
dawehnerThis is looking great!
There are no usecases for that field yet.
Comment #21
alexpottThis issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed c7fd064 and pushed to 8.0.x. Thanks!