I recently upgraded term_fields from 1.6 to 2.x-dev and find that I am now unable to save term_field data while editing a term.
I am attempting to debug the problem, but this is what I have found so far:
* The update.php process ran without outputting an error
* There was no data lost (neither field values nor entire field definitions themselves)
* When editing a term in 2.x, any pre-existing field data is populated on the form. However, any changes to that data is not saved to the database.
* If I change any values in the database directly, those changes will show up on the term edit form.
* If I uninstall term_fields entirely and install 2.x from scratch, the module functions properly.
* A quick glance at the tables in MySQL indicates that the scheme is the same between my upgraded 1.x->2.x database and the database with a 2.x-from-scratch install.
Any thoughts? I'll report back if I find out anything else.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | term_fields-1356140-3.patch | 1.15 KB | kmonty |
Comments
Comment #1
kmontyDowngrading the priority to major, as the possibility exists that this is something on my end.
Comment #2
kmontyOkay, I found the problem.
In the upgrade process, we call term_fields_update_6101(), which adds a vid field to {term_fields_terms} on line 185:
The problem is we never assign a value for each row's vid, so every upgraded row is given a vid of 0.
In term_field.module's hook_taxonomy() implementation, on $op term insert or update, we select where to update a row based on BOTH the tid and vid (line 241):
db_query("UPDATE {term_fields_term} SET ". implode(', ', $nulls) ." WHERE tid = %d AND vid = %d", $args);Of course, every upgraded row has a vid of 0, so this query returns no results.
The quick solution is to remove the
AND vid = %d(it's not necessary anyway), but that's not a proper solution. I'll work on figuring out the best way to update each row during the upgrade process and post a patch when it's ready.Comment #3
kmontyHere's a patch that runs a hook_update_N() function updating each row in {term_fields_term}
Comment #4
seworthi commentedPatch work great for me. Same update path.
Comment #5
b-prod commentedYou're totally right.
I put some comments in the code suffixed by "@todo" by in this case ("Add terms vid to the {term_fields_term} table;") I forgot the "@todo" string...
So I skipped this todo task (bad me!).
Fixed in the DEV version.
Comment #6.0
(not verified) commentedclarifying some points