I converted about 120 forum topics (out of about 130) to a new node type. The converted nodes seem correct, but something now seems wrong with counts of my remaining forum topics. The default view showing the forum topics lists the 10 remaining topics, but indicates with the pager that there are several more pages of topics to display. Selecting those pages results in empty lists. The forum view still seems to think there are the original number of forum topics. Any ideas on how to correct this?

Comments

sappling’s picture

After further investigation I think the problem is that the converted nodes still have the old TID referring to the original forum topic. Deleting the rows from the term_node table that linked the converted nodes to the old taxonomy corrected the problem, but it seems like node convert should have handled this.

kevin.dutra’s picture

Title: Wrong counts after conversion » Invalid taxonomy terms are not removed
Version: 6.x-1.7 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.51 KB

You're bang on with the investigation. There are other problems that arise from this too. Aside from the empty results pages you mentioned, you'll also find that the forum node next/previous links will still include the converted node (even though it's no longer a forum topic). And there may be other issues out there that aren't even specific to the forum type.

I'm attaching a patch to stop this from occurring. It removes any taxonomy terms from the node that are from vocabularies that the destination type does not have available. It also removes the line from forum_node_convert_change() that deletes all the taxonomy terms from the node. As it is right now, it doesn't even do anything because the node load/save at the end of node_convert_node_convert() pulls and then saves cached taxonomy terms. (And the rest of this patch will remove the forum term anyways.)

The one issue this patch does not address is what to do about data from the nodes that have already been converted. I can remove the term data for all nodes if the terms belong to vocabularies that aren't included in that type, but that would potentially delete a lot more data than intended because it doesn't look like Drupal core removes the term/node association when you remove a content type from a vocabulary.

kevin.dutra’s picture

StatusFileSize
new1.5 KB

Whoops, goofed that up a bit. Here's the correct one.