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.

Comments

Talkless’s picture

Title: Unapproved comment count does not update on page reload » Unapproved comment count in toolbar does not update on page reload
sumthief’s picture

As quick solution you can implement hook_comment_presasve where you'll force rebuild menu cache:

/**
 * Implements hook_comment_presave().
 */
function YOURMODULE_comment_presave(&$comment) {
  menu_cache_clear_all();
}
zendka’s picture

Version: 7.x-3.0-rc4 » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new754 bytes

I added a patch that flushes the admin menu cache whenever a comment is added or updated.

luksak’s picture

Caches need to be cleared when comments are deleted as well.

chris matthews’s picture

Component: User interface » Code
Status: Needs review » Reviewed & tested by the community

Even 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.

  • truls1502 committed 30dc447 on 7.x-3.x
    Issue #2345869 by Lukas von Blarer, zendka, Talkless: Unapproved comment...
truls1502’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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