Concering this current taxonomy.module in Drupal 6.13
// $Id: taxonomy.module,v 1.414.2.11 2009/05/13 19:38:33 goba Exp $

Updating from Drupal 5.19 to Drupal 6.13 removes term_node s above tid 39 causing taxonomy tags to be removed from nodes quite unexpected.

Examples before and after update of term_node:

node/7754

Drupal 5.19 term_node
(7754, 3),
(7754, 10),
(7754, 39),
(7754, 58),
(7754, 129),
(7754, 187),
(7754, 232),
(7754, 254),
(7754, 276),
(7754, 329),
(7754, 342),
(7754, 426),
(7754, 611),
(7754, 634);

Drupal 6.19 term_node table
(7754, 3, 7771),
(7754, 10, 7771),

node/7746
Drupal 5.19 term_node table
(7746, 2),
(7746, 3),
(7746, 5),
(7746, 7),
(7746, 15),
(7746, 23),
(7746, 36),
(7746, 134),
(7746, 371),
(7746, 506),
(7746, 644),

Drupal 6.19 term_node table
(7746, 2, 7751),
(7746, 3, 7751),
(7746, 7, 7751),
(7746, 15, 7751),
(7746, 23, 7751),
(7746, 36, 7751),

I have 640+ terms in Drupal 5.19.

taxonomy.module was not enabled during update.

Status:
Drupal 6.13
Access to update.php Protected
Cron-opgaver Sidst kørt for 2 timer 33 minutter siden
Du kan køre cron manuelt.
Database updates Updated
Drupal core update status No update data available
No information is available about potential new releases for currently installed modules and themes. To check for updates, you may need to run cron or you can check manually. Please note that checking for available updates can take a long time, so please be patient.
Filsystem Skrivbar (offentlig download-metode)
Konfigurationsfil Protected
MySQL database 5.1.26
PHP 5.2.6
PHP memory limit 64M
PHP register globals Ingen
Unicode-bibliotek PHP mbstring-udvidelse
Update notifications Aktiveret
webserver Apache/2.0.54
on Mediatemple Gridservice.

Comments

FlemmingLeer’s picture

Issue tags: +tid
FlemmingLeer’s picture

I tried to update it again from Drupal 5.19 to Drupal 6.13 with no Drupal core modules disabled

I got this error message in the log:
Failed: ALTER TABLE {term_node} ADD PRIMARY KEY (tid, vid)

But vid is added to the database and again highest tid is still 39 :/

The vocabulary is still available with all the taxonomy(ies) still in the database but nodes are connected to the original taxonomy in Drupal 5.19.

vocab is
/admin/content/taxonomy/edit/vocabulary/1

FlemmingLeer’s picture

After trying to add the missing via datamanipulation I think it's somehow related to nodes with no taxonomy 'tid' but I can figure out why :/

I changed vid to correspond to the nid, but what happens is that Drupal counts and then shows the counted nid instead of the nid associated tid.

Somehow Drupal counts to nid=7700 and shows nid=7700 tid, but the actual is nid=7754

The result is that nodes that have tid in Drupal 5.19 does not have it in Drupal 6.13

I have disabled cache on the update site btw.

FlemmingLeer’s picture

How to solve this term_node update problem:

Drop term_node table

Import the old term_node table from Drupal 5.x

Then manually add

vid after nid in phpmyadmin

with the following

field name
vid

datatype
INT

length
10

Collation
choose nothing

Attributes
unsigned

Null value
not null

standard value
don't write anything yet

Extra
choose nothing

Choose index in 4th button from the right of the comment field

Don't write any comment

and hit execute

I chose no standard value when setting up just in case.

The problem connected to this is that there are deleted nodes in term_node from Drupal 5.x

Find all empty nodes
SELECT DISTINCT nid FROM `term_node` t WHERE (SELECT count( * ) FROM node n WHERE t.nid = n.nid) = 0

Via this comment:
http://drupal.org/node/345080#comment-1214589

I could not delete these nodes in phpmyadmin because of an error message 1054.

Export the found empty nodes in term_nodes to sql and download them.

Enter a text editor and change all found nodes by search and replacing

(
with
DELETE FROM `term_node` WHERE `nid` =

and
) with
;

This is the result from empty nodes search:

(463),
(464),
(1935),
(1936),
(1937),
(1938),
etc.

to this end result:

DELETE FROM `term_node` WHERE `nid` = 463;
DELETE FROM `term_node` WHERE `nid` = 1935;
DELETE FROM `term_node` WHERE `nid` = 1936;
DELETE FROM `term_node` WHERE `nid` = 1937;
DELETE FROM `term_node` WHERE `nid` = 1938;
etc.

Copy paste into phpmyadmin and they are finally gone !

Then use this mysql to update vid column:

UPDATE term_node t SET vid = (SELECT vid FROM node n WHERE t.nid = n.nid)

Via this comment:
http://drupal.org/node/345080#comment-1205079

And you almost there....

change vid and enter 0 as standard value

Then delete the old Drupal 5.x primary key for term_node
ALTER TABLE `term_node` DROP PRIMARY KEY

Then do this mysql command:

ALTER TABLE term_node ADD PRIMARY KEY (tid, vid)

And you all done :/

And now somebody add this to the update process from Drupal 5.19 to Drupal 6.13 !

Please :/

heine’s picture

Status: Active » Closed (duplicate)
airforcefawaz’s picture

thanx all

hillaryneaf’s picture

Thanks for the documentation on how to fix this! It's a life saver.

I've noticed a new issue that I'm not sure is related to the above.

yngens’s picture

kudos to you, FlemmingLeer! saved me from lot's of headaches.

FlemmingLeer’s picture

Version: 6.13 » 6.20
Status: Closed (duplicate) » Active
Issue tags: +Drupal 5.23, +Drupal 6.20

Thanks, you guys.

Aaaand it's still a bug !

I can confirm that this problem still exist in Drupal 6.20 :/

heine’s picture

Status: Active » Closed (duplicate)