Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
comment.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 May 2014 at 22:53 UTC
Updated:
29 Jul 2014 at 23:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leerscomment-unit-test.patch queued for re-testing.
Comment #3
sunComment #4
wim leersNo!
This must explicitly remain a user with only the 'access comments' permission, for the reasons outlined in #2099131-201: Use #pre_render pattern for entity render caching.
Comment #5
wim leersComment #6
wim leersComment #7
effulgentsia commented#5 looks good, but given the comment in the interdiff, is it a problem that the original patch passed? Are we missing an assertion related to unpublished comments?
Comment #8
wim leers#7: It says "published comment" in the code comment because that's what
CommentDefaultFormatter's if-test says. But the reason I'm insisting on using'access comments'is because the condition to render comments that applies to 99% of users (who don't have the permission to administer comments) looks like this:(($entity->get($field_name)->comment_count && $this->currentUser->hasPermission('access comments'))And in my work on #2099131: Use #pre_render pattern for entity render caching, I discovered that
$comment->save()did NOT reset the commented entity's storage cache, which causedcomment_countto remain at zero, even after comments were posted.Giving users all permissions tests the 1% case, giving the user only permission to access comments tests the 99% case.
Hopefully this is more clear. But I know, it's confusing and frustratingly complex. Again, see #2099131-201: Use #pre_render pattern for entity render caching for all the details, and an interdiff that shows the problems explicitly.
Comment #9
effulgentsia commentedIf we don't have one, a separate unit test for this would be good, rather than solely testing it incidentally in a formatter's test. But regardless, that's separate scope from this issue. #5 is closer to HEAD than the original patch, so RTBC.
Comment #10
wim leersAgreed.
The key problem is that
CommentDefaultFormatterwas added with ZERO test coverage. I only added the regression test coverage needed to prevent regressions of the bugs I fixed and discovered while working on something completely independent.Comment #11
catchCommitted/pushed to 8.x, thanks!
Comment #13
dawehnerMh, sadly this test does not really work as you would expect it and causes kind of "random" failures on other patches, see #2263329: CommentDefaultFormatterCacheTagsTest just works because nothing uses AccountProxyInterface in HEAD
Comment #14
dawehnerHa, effulgentsia should have know that better.