Problem/Motivation

comment_entity_load() adds comment statistics information to entity object on a per-field basis. It gets it's data from read() on comment.statistics. Problem is that read() keyes return array with entity_id, which results in values being overriden if there are more than one comment field on an entity.

Proposed resolution

Do not key return array by entity_id to actually pass over stats for all fields.

Remaining tasks

- write fix
- write test coverage

User interface changes

N/A

API changes

- array that is returned form CommentStatisticsInterface::read() is slightly changed

Comments

slashrsm’s picture

Status: Active » Needs review
StatusFileSize
new3.45 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2292115_1.patch, failed testing.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB
new1.82 KB
larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, good find.

slashrsm queued 3: 2292115_3.patch for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: 2292115_3.patch, failed testing.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB

Re-roll.

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Simple re-roll.

catch’s picture

So fixing this is good, but I think we should also look at whether we actually need this to be loaded into the entity object at all. For listings there is hook_entity_prepare_view() which might well be enough.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8b72eb1 and pushed to 8.x. Thanks!

alexpott’s picture

We can explore #9 in another issue.

  • alexpott committed 8b72eb1 on 8.x
    Issue #2292115 by slashrsm: Fixed Comment statistics is no correctly...
andypost’s picture

@catch

but I think we should also look at whether we actually need this to be loaded into the entity object at all

Yes we need them, at least for #1920044: Move comment field settings that relate to rendering to formatter options
This is only place where we can load comment field related data

Status: Fixed » Closed (fixed)

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

roderik’s picture

I didn't see this issue until I spotted the commit in the D8 commit log last month...

...this was my fault since I pushed #2259209: Fix CommentStatistics::read() in, which should apparently have been named "break CommentStatistics::read()" instead...

...but since I know I'm the only one using the change in #2259209, and it's not necessary anymore: I'd really like to revert the behavior to before #2259209. See #2318875: Redo CommentStatisticsInterface for details. Sorry, and thanks for the tests.