Fixed Approval queue

Mark3121

Well-known member
Affected version
2.1.1
We have manual registrations that only admin can approve. For moderators the approval queue badge showing how many is in the queue shows a wrong higher number as it counts the number of waiting registrations which the moderator cant see.

Any reason why the mod tools link stays shown when it's queue is empty? Seems strange as it just links to the approval queue which is rightly hidden when empty.
 
Our issue might be the same issue, so I will report it here.

Occasionally, the moderators see the number of unapproved registrations instead of the number of unapproved threads. The moderators have no access to approve registrations, so they should never be seeing the larger number.

Edit: version 2.1.2
 
I've attempted to reproduce this and I have been unable to. My test conditions so far have been fairly simple.

I have a moderator account (mine) which has permission to do everything. I have a thread and a user awaiting approval so I see:

205663

I have another moderator account which has permission to do everything EXCEPT "Approve / reject users". This user sees:

205664

Throughout the code when we calculate the number of items, we grab all approval queue entries, then filter them based on what the user is able to see. I can't see any scope for this falling over.

Therefore we'd need to see if this is an issue with an add-on or if there are other reproduction steps that we're missing.
 
It is an intermittent problem, so you wouldn't see it all the time. I would call it a somewhat rare occurrence, but it obviously is happening.

Add-ons: I've got a few, but I can't see how they would interfere. I also can't just disable them all for a day.

If there is some code that I could add to log variables, I'm happy to test it. Basically, a moderator/supermoderator should never see a number bigger than 100 in my forums. If they do see a large number, we know there is a problem.

Something like:
if (supermoderator and $count > 100){​
dump variables to a file​
}​
 
I can confirm. This bug exists.
For reproducing, approving/declining operation should be executed not from queue. For threads/posts - from thread page, for resources - from resource page.
If operation executed from Approval Queue, counter recalculates correctly.
 
Throughout the code when we calculate the number of items, we grab all approval queue entries, then filter them based on what the user is able to see. I can't see any scope for this falling over.
Correct me, if i am wrong.
  1. For threads (for example), we going to XF\Service\Thread\Approver::approve().
  2. In XF\Entity\Thread::_postSave(), we delete relationed entity XF\Entity\ApprovalQueue.
  3. This action (in XF\Entity\ApprovalQueue::_postDelete()) triggers internal method rebuildUnapprovedCounts().
  4. This internal method just run once XF\Repository\ApprovalQueue::rebuildUnapprovedCounts().
Now, let's go see this method, and see simple query SELECT COUNT(*) FROM xf_approval_queue. Without any filtering, what user can see.
 
Last edited:
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.4).

Change log:
Ensure the unapproved counts are recalculated correctly and take content visibility into account.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
How to access Approval Queue please help

This:
All the approvals are done on the front end now not in the ACP.

If there are none in approval currently, then you'll see the approval que under the moderator menu. But you will still a separate approval que section when approving new members into the forum. Also make sure you set administrators as moderators as well or they won't see the approval que.
 
We just updated and are still having the same problem - full thread detailing and documenting is below.

Screenshot_2019-09-26 Working On It - Approval Queue Counter Stuck .png
Screenshot_2019-09-26 Working On It - Approval Queue Counter Stuck (1).png
Just noticed that my images are too small to read. Basically, I get inconsistent stuck counter counts. There appears to be no ryhme or reason to how it occurs, approve one at at time = variable result. approve all at once = variable result. Refresh or not? Random results.
 
Last edited:
Hi
We had the issue where the approval queue counts are incorrect or the content for approval is not showing

Please see the following screenshot.

We have updated to XF 2.1.4 as the changelog stated that this issue would be fix - but
this has not cured the issue. It would be great if we could get a fix.

Many thanks Nick
 

Attachments

  • bad-queue.pn.webp
    bad-queue.pn.webp
    28.2 KB · Views: 19
Does that count of 10 reflect the number of unapproved items before they were actioned? Or does that count reflect how many entries are in the xf_approval_queue table?

We need to try and ascertain where that incorrect count is coming from.
 
I think there could be further issues here.

We may be conflating the "global" cache of the count of unapproved items with the user-specific "local" cache of unapproved items which is saved in a user's session.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.6).

Change log:
Apply proper fix to ensure the user's correct approval queue counts are displayed.
There may be a delay before changes are rolled out to the XenForo Community.
 
It's fixed for the next release, but here's a diff if you wanted to apply the fix yourself.

Diff:
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
Is that ok for you to work with or do you need me to be more specific about the changes to apply?
 
Top Bottom