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.
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'))
return;
//Get discussionID that is being deleted
$DiscussionID =$Sender->EventArguments['DiscussionID'];
//Get List of tags to reduce count for
$TagDataSet = Gdn::SQL()->Select('TagID')
->From('tagdiscussion')
->Where('DiscussionID =',$DiscussionID)
->Get();
while ($SingleTag = $TagDataSet->NextRow(DATASET_TYPE_ARRAY)) {
$RemovedTagIDs[]=$SingleTag['TagID'];
}
//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.
Comments
/** * !!!! 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')) return; //Get discussionID that is being deleted $DiscussionID =$Sender->EventArguments['DiscussionID']; //Get List of tags to reduce count for $TagDataSet = Gdn::SQL()->Select('TagID') ->From('tagdiscussion') ->Where('DiscussionID =',$DiscussionID) ->Get(); while ($SingleTag = $TagDataSet->NextRow(DATASET_TYPE_ARRAY)) { $RemovedTagIDs[]=$SingleTag['TagID']; } //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'); } }
http://vanillaforums.org/addon/tagging-plugin-1.0.0