Updated: Comment #8
Problem/Motivation
Function comment_count_unpublished()
is used only as title of local task UnapprovedComments
(added in #2032309: Use local tasks derivatives to provide local tasks for views) and does not support a swapable comment storage, because could not be overriden
Proposed resolution
Implement CommentStorageInterface::getUnapprovedCount()
that uses EntityQuery
to count unapproved comments
API changes
remove comment_count_unpublished()
add CommentStorageInterface::getUnapprovedCount()
Original report by @andypost
Follow-up from #1978904: Convert comment_admin() to a Controller
Also usage of the function ('title callback' => 'comment_count_unpublished',
) should be replaced with proper method in storageController
Comment | File | Size | Author |
---|---|---|---|
#29 | issue-2111357-29.patch | 4.18 KB | marcingy |
Comments
Comment #1
andypostFollowing #2068325: [META] Convert entity SQL queries to the Entity Query API we should use Entity Query API
The second level tabs seems should wait for #2102125: Big Local Task Conversion
Comment #2
jibranLet's add @deprecate and add @todo in hook_menu for local task conversion.
Comment #3
tstoecklerSo I guess this function should be called *Unpublished not *Unapproved?!
Naming suggestion: getUnapprovedCount() or even countUnapproved()
Comment #4
andypostNot sure that it makes sense to put that into manager class because:
- the conversion #2068331: Convert comment SQL queries to the Entity Query API moves this to storage controller
- maybe better to follow #2068331-32: Convert comment SQL queries to the Entity Query API and implement special data classes
Also related
#2054993: Remove (untested, unused, broken) comment_get_recent()
#1961548: [Policy, no patch] Decide how the module-specific services are made available as static methods (similar to \Drupal::$service())
Comment #5
andypostAnther approach, the only place where this function used - local task (tab) in admin/content/comment
So I think better to get rid of it and move query in corresponding plugin class
PS: need approval from commiters
Comment #7
andypostright patch
Comment #8
andypostDiscussed with @msonnabaum and he suggest to implement the method in manager because this method uses storage details
Comment #9
larowlanWe should be typehinting the QueryFactoryInterface.
Other than that RTBC
Comment #10
areke CreditAttribution: areke commentedThe patch should be re-rolled because it doesn't apply against the current HEAD. Also, @larowlan is right so the proposed change noted in #9 should be made.
Comment #11
andypostI found that
QueryFactoryInterface
is not used in core andQueryFactory
is different from interface?!Anyway here is re-roll and interface related code
Comment #13
andypostI don;t know why
Drupal\Core\Entity\Query\QueryFactory
does not implementsQueryFactoryInterface
so asked in #2019651-15: Add a QueryFactoryInterface for QueryFactory classesComment #14
andypost13: 2111357-comment-approved-count-13.patch queued for re-testing.
Comment #15
larowlanComment #16
webchickHm. I guess this is OK since CommentManagerInterface is currently a grab-bag of methods that each do absolutely nothing to actually manage comments. :P~ FWIW though, I had envisioned this interface basically containing comment CRUD but instead it's a random assortment of methods with absolutely no rhyme or reason to why they exist grouped together that I can see.
I was going to commit this anyway, since it doesn't make what's already a bad situation tangibly worse, but apparently someone already did.
Comment #18
marcingy CreditAttribution: marcingy commentedSo this seems like it never actually got committed as the function still exists - I assume this will fail a retest
Comment #19
marcingy CreditAttribution: marcingy commented13: 2111357-comment-approved-count-13.patch queued for re-testing.
Comment #21
marcingy CreditAttribution: marcingy commentedNo interdiff as we now have a comment storage service, so couldn't get anything clean. Code is otherwise the same just in a new home.
Comment #22
marcingy CreditAttribution: marcingy commentedComment #23
marcingy CreditAttribution: marcingy commentedComment #25
marcingy CreditAttribution: marcingy commentedTake 2
Comment #27
marcingy CreditAttribution: marcingy commentedOk bit better still getting local fails but my machine is also hating me at the moment.
Comment #29
marcingy CreditAttribution: marcingy commentedComment #30
andypostNeeds this in #1498662: Refactor comment entity properties to multilingual
OTOH maybe reuse entity query here
Comment #31
slashrsm CreditAttribution: slashrsm commentedComment #32
webchickCommitted and pushed to 8.x. Thanks!
Comment #35
roderikHm, followup needs review: move this to CommentManager for consistency.
(see also https://www.drupal.org/node/2156089#comment-8273841 / https://www.drupal.org/node/2068331#comment-8917365)
edit: let's mention the issue # then :) #2318539: Move CommentStorage::getUnapprovedCount() to CommentManager