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 various fields in CommentViewsData that are currently using custom handlers from the Comment module:
- 'comment' handler for comment_field_data.subject and comment_field_data.cid
- 'comment_username' handler for comment_field_data.name ==> This is now a separate issue #2454163: Replace comment_username handler with generic views handler
- 'comment_depth' used for comment_field_data.thread

Proposed resolution

Change all of these to use the Field API formatter 'field' instead of the custom formatter. Should also be able to remove the custom formatters from the code base completely. That last one may need to have a custom handler, but if so it needs to derive from the Field API formatter so that it does the right thing with respect to entity access and translation.

Remaining tasks

Make a patch.

User interface changes

None.

API changes

Not really.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adamwhite’s picture

Status: Active » Needs review
FileSize
5.92 KB

Here's the first pass at this. It doesn't handle the changes related to comment_depth as of yet. If comment_depth is switched to 'field' instead of the custom formatter the output in views indeed doesn't look right as suggested in the proposed resolution. Next step providing this patch passes would be to switch the Depth class to derive from the Field API formatter.

adamwhite’s picture

That patch will fail testing as per issue #2090115 which moved the physical location of the install yml files from where they were when I rolled the patch. I'll re-roll and re-submit.

adamwhite’s picture

Same patch as before reflecting the move of those yml files to the optional subdirectory in issue #2090115.

The last submitted patch, 1: comment-views-field-handlers-2456705-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: comment-views-field-handlers-2456705-3.patch, failed testing.

jhodgdon’s picture

Clarification on #6 -- that separate issue is for the "field_name" field, not "name".

xjm’s picture

Issue tags: +VDC
dawehner’s picture

Status: Needs work » Needs review
FileSize
10.03 KB
9.75 KB

Some work on it.

Status: Needs review » Needs work

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

dawehner’s picture

Status: Needs work » Needs review
FileSize
10.7 KB
1.24 KB

Let's fix stuff.

Status: Needs review » Needs work

The last submitted patch, 11: 2456705-11.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.46 KB
1.67 KB

Alright.

effulgentsia’s picture

Issue tags: +Critical Office Hours

Per #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.

effulgentsia’s picture

The issue summary says the scope of this issue includes comment_username and comment_depth, but those conversions aren't in the patch yet. Meanwhile, #2454163: Replace comment_username handler with generic views handler is open as a separate issue without a patch and not yet prioritized as critical. Should we close that as a duplicate or does it make sense for that to be split out?

dawehner’s picture

FileSize
1.15 KB
12.61 KB

Should we close that as a duplicate or does it make sense for that to be split out?

I think it makes sense to have it split up, given that this issue doesn't need yet a new handler yet.

I adapted the comment_depth one, given that I see no usecase in exposing that as a formatter to be honest.

jhodgdon’s picture

Editing summary for scope, and linking to related issue.

dawehner’s picture

FileSize
18.3 KB
5.69 KB

We should be able to remove the handlers now.

larowlan’s picture

Pretty close here, only nits and one question about a deletion

  1. +++ /dev/null
    @@ -1,122 +0,0 @@
    -<?php
    

    Less code++

  2. +++ b/core/modules/comment/src/Plugin/views/field/Depth.php
    @@ -17,15 +17,20 @@
    +      $item['rendered']['#markup'] =  count(explode('.', $comment_thread)) - 1;
    

    nitpick two spaces after the =

    note to self: this should be a method on CommentInterface cause we do it a few times in Comment class too.

  3. +++ /dev/null
    @@ -1,39 +0,0 @@
    -  public function render(ResultRow $values) {
    

    Removing this file seems unrelated - if we remove it, we need a formatter to replace it? Or is this totally unused because the 'comment' column on {node} is loooong dead?

  4. +++ b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
    @@ -114,19 +114,20 @@ protected function setUp() {
    +    $user = $this->drupalCreateUser(['access comments']);
    

    Love that we had tests that validated insecure access to comments.

  5. +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php
    @@ -105,6 +105,12 @@ function testPageCacheTags() {
    +    // Render the view block adds the languages cache context.
    

    %s/Render/Rendering?

  6. +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php
    @@ -105,6 +105,12 @@ function testPageCacheTags() {
    +    // As the languages is the parent of the languages::LanguageInterface::TYPE_INTERFACE
    

    nitpick >80

YesCT’s picture

fixed the nits. question from 19.3 still unanswered.

Status: Needs review » Needs work

The last submitted patch, 20: 2456705.20.patch, failed testing.

dawehner’s picture

Removing this file seems unrelated - if we remove it, we need a formatter to replace it? Or is this totally unused because the 'comment' column on {node} is loooong dead?

Yeah, that handler is not used at all anymore in views.

Thank you @yesct for fixing the review points!

dawehner’s picture

Status: Needs work » Needs review
FileSize
18.09 KB
936 bytes

Let's fix the failures.

larowlan’s picture

Tried to manually test on simplytest.me, didn't apply - re-roll

larowlan’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
77.45 KB

Shots from manual testing, comments on left, view on right

andypost’s picture

+++ /dev/null
@@ -1,39 +0,0 @@
-class NodeComment extends FieldPluginBase {

But there's still the same named filter plugin. But it has nothing about node

dawehner’s picture

But there's still the same named filter plugin. But it has nothing about node

Well, we just care about field handlers here.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Looks like we need to update CommentViewsFieldAccessTest.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
19.42 KB
1.32 KB

Sure.

alexpott’s picture

FileSize
19.42 KB

Testbot please test.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: 2456705-29.patch, failed testing.

The last submitted patch, 29: 2456705-29.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
20.9 KB
1.48 KB

Fixed those test failures.

webchick’s picture

Issue tags: +Triaged D8 critical

@alexpott, @effulgentsia, @xjm and I discussed this on a D8 critical triage call today. Since comments are a content entity, like nodes and taxonomy terms, I think the expectation of users would be that access control would be respected in any given display, and if this wasn't fixed prior to release would likely result in an SA. Therefore, tagging as a triaged critical.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Ready to go

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 33: 2456705-33.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
20.89 KB

Applied again ... #2450153: Add a default_formatter to UUIDs fields conflicted with it.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed dc47451 and pushed to 8.0.x. Thanks!

  • alexpott committed dc47451 on 8.0.x
    Issue #2456705 by dawehner, adamwhite, larowlan, YesCT: Comment views...

Status: Fixed » Closed (fixed)

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