It's very handy to see unapproved comment count in toolbar under Content -> Comments -> Unaproved comments (X), but this number updates rather.. rarely.
If new comment is posted, this count will update only after when Drupal caches are cleared or administrator re-logins into site.
I've tested it in clean new Drupal installation using Firefox 32.0.3. I login as administrator, and at the same time, inside Firefox private browsing mode, I create new comment using anonymous user. Then, after comment is saved and queued, administrator reloads page and "Unapproved comments" stays the same (it might be 0 or 1 or whatever old value).
Even if I open comment approval page, with that one new comment, Toolbar menu item still shows old value. See screenshot attached.
Comment | File | Size | Author |
---|---|---|---|
#4 | admin_menu-refresh_comment_count-2345869-4.patch | 967 bytes | Lukas von Blarer |
#3 | admin_menu-refresh_comment_count-2345869-3.patch | 754 bytes | zendka |
admin_menu_toolbar_unaproved_comments.png | 37.89 KB | Talkless |
Comments
Comment #1
Talkless CreditAttribution: Talkless commentedComment #2
sumthief CreditAttribution: sumthief commentedAs quick solution you can implement hook_comment_presasve where you'll force rebuild menu cache:
Comment #3
zendka CreditAttribution: zendka as a volunteer commentedI added a patch that flushes the admin menu cache whenever a comment is added or updated.
Comment #4
Lukas von BlarerCaches need to be cleared when comments are deleted as well.
Comment #5
Chris Matthews CreditAttribution: Chris Matthews commentedEven though the patch in #4 is about a year old it still applies cleanly to 7.x-3.x-dev and fixes this issue for me. Changing the status to RTBC in hopes this gets committed before the next 7.x release, be it -rc7 or 7.x-3.0.
Comment #7
truls1502