Fixed [Speed Up] No need to rebuild moderation queue if no rows affected

guiltar

Well-known member
Hello!

There is a method.
PHP:
    public function deleteFromModerationQueue($contentType, $contentIds)
    {
       ....

        $db = $this->_getDb();
        $db->delete('xf_moderation_queue',
            'content_type = ' . $db->quote($contentType) . ' AND content_id IN (' . $db->quote($contentIds) . ')'
        );

        $this->rebuildModerationQueueCountCache();
    }

I suggest not to rebuild moderation queue if no rows affected. It causes db locks if the content is being deleted often. Suggestion:
PHP:
    public function deleteFromModerationQueue($contentType, $contentIds)
    {
       ....
        $db = $this->_getDb();
        $affectedRows = $db->delete('xf_moderation_queue',
            'content_type = ' . $db->quote($contentType) . ' AND content_id IN (' . $db->quote($contentIds) . ')'
        );
        if($affectedRows)
             $this->rebuildModerationQueueCountCache();
    }
 
Top Bottom