The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
"Unapproved" Commen...
 
Share:
Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

"Unapproved" Comments are Visible

6 Posts
3 Users
2 Reactions
132 Views
Posts: 3
Topic starter
(@gelaw)
Active Member
Joined: 3 weeks ago

Hi. I experienced the same problem yesterday, where a reader not admin, not even connected saw a comment which wasn't yet approved (and wasn't their's).

WhatsApp Image 2025 07 27 à 15.17.09 2b631c48

 A staff member managed to recreate the issue while not connected, though we can't recreate it anymore. there was over 80 comments at the time the issue occured.
A clear of comment cache might have removed the problem
"Use Wordpress native Ajax functions" is unchecked
Cache is enabled
he is the link to the post Une professeure obtient la suspension de sa mutation à Paris

Thanks for your help.

5 Replies
Asti
Posts: 8075
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 years ago

Hi,

This should be a cache issue. Please disable all kinds of cache systems and check again. 

Reply
Posts: 3
Topic starter
(@gelaw)
Active Member
Joined: 3 weeks ago

Hi. Disabling any and all caches on a live service to detect a transient issue isn't feasible on our infrastructure.
Instead here is possibly the source of the issue:
in /utils/class.WpdiscuzHelper.php :

    public function isUnapprovedInTree($comments) {
        foreach ($comments as $comment) {
            if ($comment->comment_approved === "0") {
                return true;
            }
            if ($children = $comment->get_children()) {
                return $this->isUnapprovedInTree($children);
            }
        }

        return false;
    }

This function is used to determine if comments are cacheable but contains a logic mistake, where if an "approved branch" is read first, the function skips the rest of the tree returning false.

one way to fix this issue in the code would be:

    public function isUnapprovedInTree($comments) {
        foreach ($comments as $comment) {
            if ($comment->comment_approved === "0") {
                return true;
            }
            if ($children = $comment->get_children()) {
                if($this->isUnapprovedInTree($children)){
                    return true;
                }
            }
        }

        return false;
    }

the difference being: if an unapproved leaf is found, we can say for sure the whole contains unapproved comment, but otherwise we still need to check the rest of the tree.

i could not reproduce it, but here is the next best thing i found:

cd [path-wpdiscuz-cache]/cache/comments/ && grep -ari 's:16:"comment_approved";s:1:"0";'

returning elements, ie unapproved comment in the cache maintained by wpdiscuz.
As a last note: this might not be the only source of this peculiar issue, just the one i found.

Reply
2 Replies
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8075

@gelaw,

Please provide us with a detailed list of the steps you’ve taken, so we can try to replicate the issue on our test websites for further investigation.

At the moment, we’re unable to reproduce the same issue on our end.

Reply
(@gelaw)
Joined: 3 weeks ago

Active Member
Posts: 3

@asti 
Sure, here's a possible scenario that may help you reproduce or understand the issue:

_wpDiscuz caching is enabled

_“Use WordPress native Ajax functions” is unchecked

_A post has nested comments (threaded replies are active)

_A new comment is submitted and goes into pending moderation

_The internal method isUnapprovedInTree() returns false due to a short-circuit logic flaw

_As a result, the entire comment tree (including the pending comment) is cached and may be served to all visitors, even if they are logged out

This only occurs when:

_An unapproved comment is not in the first branch of the tree evaluated by isUnapprovedInTree()

_The comment structure is nested

_The some timing dependant of cache, fetch

Although I haven’t consistently reproduced the issue visually on the site, I was able to find cached files that contained unapproved comments using this:
From the folder of the plugin cache
grep -ari 's:16:"comment_approved";s:1:"0";' comments/

This confirms that unapproved comments can be serialized into the HTML cache.

I understand the value of being able to reproduce the issue, but in this case, the code path in isUnapprovedInTree() contains a clear logic flaw that can be reviewed directly by your development team. Providing them with the logic and fix I shared earlier may help resolve the issue without relying on uncertain reproduction steps. This would be the reason why me and @dailynous had high comment count when we observed the issue.

Reply
Posts: 7
(@dailynous)
Active Member
Joined: 2 years ago

@gelaw, Thank you very much for this detailed and careful analysis of the problem.

@asti, I hope WPDiscuz takes advantage of this assistance from @gelaw and is able to update the plugin and fix the problem. Let us know if that's going to happen. Thanks.

Reply
Share: