diff --git a/src/XF/Pub/App.php b/src/XF/Pub/App.php
index 0c89d8f316..dbbba66384 100644
--- a/src/XF/Pub/App.php
+++ b/src/XF/Pub/App.php
@@ -320,11 +320,14 @@ protected function updateModeratorCaches()
{
/** @var \XF\Repository\ApprovalQueue $approvalQueueRepo */
$approvalQueueRepo = $this->repository('XF:ApprovalQueue');
- $unapprovedCache = $approvalQueueRepo->rebuildUnapprovedCounts();
+
+ $unapprovedItems = $approvalQueueRepo->findUnapprovedContent()->fetch();
+ $approvalQueueRepo->addContentToUnapprovedItems($unapprovedItems);
+ $unapprovedItems = $approvalQueueRepo->filterViewableUnapprovedItems($unapprovedItems);
$unapprovedCounts = [
- 'total' => $unapprovedCache['total'],
- 'lastBuilt' => $unapprovedCache['lastModified']
+ 'total' => $unapprovedItems->count(),
+ 'lastBuilt' => $registryUnapprovedCounts['lastModified']
];
$session->unapprovedCounts = $unapprovedCounts;
diff --git a/src/XF/Repository/ApprovalQueue.php b/src/XF/Repository/ApprovalQueue.php
index 33f21b68ed..09a43f8e86 100644
--- a/src/XF/Repository/ApprovalQueue.php
+++ b/src/XF/Repository/ApprovalQueue.php
@@ -202,17 +202,12 @@ public function filterQueue(array $queue)
public function rebuildUnapprovedCounts()
{
- $unapprovedItems = $this->findUnapprovedContent()->fetch();
- $this->addContentToUnapprovedItems($unapprovedItems);
- $unapprovedItems = $this->filterViewableUnapprovedItems($unapprovedItems);
-
$cache = [
- 'total' => $unapprovedItems->count(),
+ 'total' => $this->db()->fetchOne('SELECT COUNT(*) FROM xf_approval_queue'),
'lastModified' => time()
];
\XF::registry()->set('unapprovedCounts', $cache);
-
return $cache;
}
}
\ No newline at end of file