I think the problem is with the intended fix to avoid duplicates in the tree.
Your new select requires that b.nid = b.vid. If I understand correctly, nid is the node ID, vid is the version (revision) ID. The two won't match in most cases. I think you need the record with the highest vid for the given nid.

Comments

kofa’s picture

Given it more time I see that duplicates were caused by different weight numbers in different versions of a node. A subselect could probably be used to get max(vid), but we're on MySQL 4, which does not support subselects.
Not having either many duplicates or spare time, I cleaned up the DB by hand:
SELECT n.title, b.nid, COUNT(DISTINCT b.weight) AS weights FROM book b, node n WHERE b.nid=n.nid GROUP BY n.title, b.nid HAVING weights>1 ORDER BY nid;
This lists all the titles that will turn up as duplicates.
One can then select the latest version:
SELECT nid, max(vid) FROM book WHERE nid IN (1,2,7 [list nids reported above here]) GROUP BY nid;
Then
SELECT weight FROM book WHERE nid = 1 [a broken nid] AND vid = 10 [max. vid reported by above max(vid) query];

Or list all versions of each page (maybe you set the wrong weight in your last revision):
SELECT nid, vid, weight FROM book ORDER BY nid;

Finally, set the same weight for all revisions:
UPDATE book SET weight = 4 [new desired weight] where nid = 1 [the broken nid used above];

uccio’s picture

Assigned: Unassigned » uccio
Status: Active » Fixed

Hi Kofa,

Try the latest version of module and tell me if now is all OK!!

bye Uccio

Anonymous’s picture

Status: Fixed » Closed (fixed)