Skip to content

Commit

Permalink
Reverse conditional logic for comment status transition testing. See w…
Browse files Browse the repository at this point in the history
  • Loading branch information
JasWSInc committed Aug 8, 2014
1 parent 1ecaf51 commit 4b13283
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions quick-cache-pro/quick-cache-pro.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2080,21 +2080,16 @@ public function auto_purge_comment_transition($new_status, $old_status, $comment
if(empty($comment->comment_post_ID))
return $counter; // Nothing we can do.

// @TODO @raamdev I think it would a good idea to reverse the logic here to match other routines.
// Perhaps we could check for a negated condition and stop before proceeding; instead of the other way around.

if($old_status === 'approved' || ($old_status === 'unapproved' && $new_status === 'approved'))
{
$counter += $this->auto_purge_xml_feeds_cache('blog-comments');
$counter += $this->auto_purge_xml_feeds_cache('post-comments', $comment->comment_post_ID);
$counter += $this->auto_purge_post_cache($comment->comment_post_ID);
}
else // Don't allow next `auto_purge_post_cache()` call to clear post cache.
// Also, don't allow unapproved comments not being Approved to clear cache.
if(!($old_status === 'approved' || ($old_status === 'unapproved' && $new_status === 'approved')))
// If excluded here, don't allow next `auto_purge_post_cache()` call to clear post cache.
{
static::$static['___allow_auto_purge_post_cache'] = FALSE;
return $counter; // Nothing to do here.
}
$counter += $this->auto_purge_xml_feeds_cache('blog-comments');
$counter += $this->auto_purge_xml_feeds_cache('post-comments', $comment->comment_post_ID);
$counter += $this->auto_purge_post_cache($comment->comment_post_ID);

return apply_filters(__METHOD__, $counter, get_defined_vars());
}

Expand Down

0 comments on commit 4b13283

Please sign in to comment.