Updated: Comment #0
Problem/Motivation
The function used only in theme layer and could be removed in #1938062: Convert the recent_comments block to a view
Also theme function should be changed in twig conversion in #1987396: Refactor & Clean-up comment.module theme functions
Ordering needs fix #1059608: Fix comment_get_recent ordering
Proposed resolution
Move query to current implementation of block to allow contrib inherit the block and change the query.
Remaining tasks
Approve API cleanup
User interface changes
No
API changes
Change theme function arguments
Remove function
Related Issues
#1938062: Convert the recent_comments block to a view
#1987396: Refactor & Clean-up comment.module theme functions
#1059608: Fix comment_get_recent ordering
Comment | File | Size | Author |
---|---|---|---|
#33 | remove-comment_get_recent.patch | 1.72 KB | andypost |
#29 | 2054993-recent-comments-29.patch | 5.24 KB | andypost |
#27 | drupal8.comment-module.2054993-27.patch | 6.02 KB | andypost |
Comments
Comment #1
andypostNo visial changes
Comment #2
tim.plunkettI think it could be a method on a CommentManager service, honestly. But, if we continue down this path:
Inject the storage controller, please
Comment #3
andypostI think it useless to have this function so better encapsulate in block where it used only
Comment #4
andypostProper patch and interdiff
Comment #5
larowlanNot fussy either way
On the manager would make it more useful to contrib/easier to reuse.
For forum I've tried to get all of the SQL queries (other than hooks) on the manager to make it easier for other backends to override in one place so that would fit here too.
But either way is better than what we have now.
Comment #6
andypostI suppose that it much better UX and DX could be found with reusable block because it's much easy to inherit block then manager
Comment #7
tim.plunkettIf I wanted to get 10 comment object for the most recent, what does that have to do with a block?
BlockManager::getRecentComments(AccountInterface $account);
Comment #8
andypost@tim.plunkett suppose once you need to query recent comments then use can use views or copy/paste code from block or just inherit block into own module and change query for your needs.
But in case this function placed into commentManager service you could only to swap service but this approach is limited because 2 modules can not swap service same time.
For example site uses contrib that replaces manager service with own implementation and developer needs new block of recent comments but for products only (the most often task) in this case only view or custom query could be used!
That's why I think that easy to copy/paste block code then service
Comment #9
tim.plunkettI think its easier to call a method than copy paste the contents of a class, but I'll probably never need this, I don't care.
But I still think it has nothing to do with blocks.
Comment #10
dawehnerIs there a reason to not use EQ or just skip all that and just do the views bit?
Comment #11
dawehnerI interpretate #1938062-82: Convert the recent_comments block to a view as a won't fix for this issue.
Comment #12
xjm@dawehner, I don't think my comment has anything to do with this issue?
It makes sense to me to not remove that function in that issue, and discuss it specifically here instead, as to whether we think it's a worthwhile procedural helper or not. I agree that the function is generic and needn't have anything to do with the block.
My two cents is that this is not serious enough to merit a BC break after API freeze. Instead, I think we should:
comment_get_recent()
inside OO code. This dovetails nicely with #1938062: Convert the recent_comments block to a view, but neither issue is dependent on the other.comment_get_recent()
and replace its innards with an EFQ.comment_get_recent()
, which is then merely a BC procedural wrapper, as@deprecated
.Comment #13
xjmComment #14
xjmComment #15
tstoecklerThis needs to additionally oder by comment.updated and only if they are the same by comment.cid. Otherwise editing comments will not make them jump to the top of the list.
Comment #16
andypost@xjm Thanx for point!
Patch introduces CommentManager with
getRecent($count)
method and deprecatescomment_get_recent()
in favour of it.Uses EQ but I leave 'node_access' tag here as it was
changed could be addressed in #1059608: Fix comment_get_recent ordering but I use it here too
Comment #17
dawehnerShameless advertisement for a different issue: #1938062: Convert the recent_comments block to a view
This feels kind of out of scope ? I would rather suggest to use the service directly
Wait, we do add node_access on a comment entity query?
Missing space before $query
... this should be int not integer.
What about using \Drupal\Core\CommentInterface[] to typehint it?
Comment #18
andypostAll addressed
As pointed in #1938062-102: Convert the recent_comments block to a view and discussed in IRC
RelationshipPluginBase.php
automatically adds access tags for all entities involved in relation. But EQ does not do that (debugged already to make sure)And while node_access tag is not applied automatically we should do this because user should not see comments from nodes that he is not allowed to access
Comment #19
dawehnerThere is no reason to not add multiple tags. ... nevertheless I think it is wrong to add one, given that this is supposed to be an api function.
Comment #20
andypostSo let's do it!
Comment #21
jibran#20: drupal8.comment-module.2054993-20.patch queued for re-testing.
Comment #23
andypostre-roll
Comment #24
andypostproper patch
Comment #24.0
andypostadded https://drupal.org/node/1059608
Comment #25
jibran24: drupal8.comment-module.2054993-24.patch queued for re-testing.
Comment #27
andypostJust a re-roll, waiting for #1938062: Convert the recent_comments block to a view
Comment #29
andypostRe-roll after #1938062: Convert the recent_comments block to a view
Comment #31
andypost29: 2054993-recent-comments-29.patch queued for re-testing.
Comment #32
tstoecklerNow that this function is completely unused after #1938062: Convert the recent_comments block to a view, do we really still need it? If we do, I think we should introduce some test coverage for it as well.
Comment #33
andypostFollowing #2158871-13: [Policy, no patch] Clearly denote when @deprecated code is slated to be removed there's still no conclusion about deprecated and removed so better to get commiter feedback on unused functions without test coverage.
Also this function is broken now
As the current implementation is broken and useless it make sense to get rid of it.
Comment #34
dawehnerI have to agree, this function is really unrealistic to be used at all and not part of some fundamental API.
Comment #35
catchIf I'm reading correctly, this should have been removed with #1938062: Convert the recent_comments block to a view but just got missed. If so I'm fine with just nuking it. Not committing right now though, but unassigning.
Comment #36
dawehner@catch
Sadly it was decided to not do it: #1938062-85: Convert the recent_comments block to a view
Comment #37
xjmThat sounds like API change approval from @catch.
For my part, +1, kill it. We just split this off to avoid blocking the conversion of the block on whether or not we could kill this. Conversion landed, so kill. :)
Comment #38
xjmOh. Accurate title.
Comment #39
xjmComment #40
xjmSorry for all the noise.
Comment #41
webchickCommitted and pushed to 8.x.