Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Vanilla 2.2.1 is now available.
Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.

Tagged error when deleting post

edited December 2010 in Vanilla 2.0 Help
When deleting a post with tags, the number of this tag is not refreshed. For example a post with the tag "board" is deleted, then the number behind the tag "board" is the same.


  • LincLinc Vanilla's Bard Detroit Vanilla Staff
  • For those who want the fix, just add this to your "class TaggingPlugin extends Gdn_Plugin" definition in class.tagging.plugin.php:

    * !!!! TEMPORARY FIX (by sprockett) !!!!!
    * Reduce counts, Remove tags, and Remove tag-discussion mapping upon deletion of Discussion
    public function DiscussionModel_DeleteDiscussion_Handler($Sender) {
    //Ensure this gets fired only if Tagging is enabled.
    if (!C('Plugins.Tagging.Enabled'))

    //Get discussionID that is being deleted
    $DiscussionID =$Sender->EventArguments['DiscussionID'];

    //Get List of tags to reduce count for
    $TagDataSet = Gdn::SQL()->Select('TagID')
    ->Where('DiscussionID =',$DiscussionID)
    while ($SingleTag = $TagDataSet->NextRow(DATASET_TYPE_ARRAY)) {

    //Check if there are even any tags to delete
    if (count($RemovedTagIDs) > 0) {
    // Step 1: Reduce count
    Gdn::SQL()->Update('Tag')->Set('CountDiscussions', 'CountDiscussions - 1', FALSE)->WhereIn('TagID', $RemovedTagIDs)->Put();
    // Step 2: Delete tag entries from table if they hit zero count.
    $Sender->SQL->Where('CountDiscussions <=', '0')->Delete('Tag');
    // Step 3: Delete mapping data between discussion and tag (tagdiscussion table)
    $Sender->SQL->Where('DiscussionID', $DiscussionID)->Delete('tagdiscussion');
  • I have uploaded an modifed version of the original Tagging plugin. This addresses the above problem, and adds another feature where you can see tags that belong in one category.
Sign In or Register to comment.