6

Resolved

Renaming a taxonomy does not work and corrupts the database

description

Problem is that you loose all the terms already created.
Another point no very clean: the Term Content Type created for the old taxonomy name, is no deleted, but you can do nothing with it because you loose the access to the old taxonomy record, this one has been deleted.
To clean the only solution is in editing the DB.

There should be a minimal warning when you update the name of a taxonmy saying that you will loose all its terms.

To reproduce:
1) Create a taxonomy named 'Product Types'
2) Add several terms : server, database, web site
3) edit the taxonomy and change its name to Category
-> you have lost all your terms .....
and no error in the log file...

but digging in the DB it appears that some work has been done to keep the terms under the new 'Category Term' content type created.

It seems that the missing element is that in the 2 tables :
Orchard_Framework_ContentItemRecord
Orchard_Framework_ContentItemVersionRecord
the corresponding records are not created (or updated ?) correctly.
So all the terms are still in the DB but part of their records point either to the new ContentType, part to the old one.

This could be recovered mainly by updating the last version of each term in Orchard_Framework_ContentItemVersionRecord to set Published, and Latest Columns to true then changing the ContentItemRecord_id to the new one.

On the philosophy of keeping the old records and recreating new ones, this has certainly been created because taxonomies could be sparsed through all the system, as un easy turn around for a global modification.
But in this situation the old taxonomy name should not disappear.
On my own, I would prefer to have everything migrated to the new name, keeping the history is a job for hercule. So updating rather then recreating would be preferable.
Problem seems to be in the fact that it is impossible to rename a content type in Orchard ?

A temporary action to prevent this database corruption would be avoiding any rename when some terms exist.
The best action is to correctly finalize the job and move or recreate terms under the new Term Content Type, which necessitate a better understanding of NHibernate than I actually have.

comments

Jetski5822 wrote Jun 7, 2013 at 10:57 PM

I was not able to reproduce on the latest 1.x branch, could you please check for me?

when you say
3) edit the taxonomy and change its name to Category

you mean change the title of the taxonomy right?

CSADNT wrote Jun 8, 2013 at 7:32 AM

As you have seen this is an old bug for v1.6.
I will try to repro with recent 1.x and give a feedback asap.

CSADNT wrote Jun 9, 2013 at 10:38 AM

Hi,

I tested this morning with a fresh orchard and the bug is still here.

Repro:

Create taxo as said above with various terms
Cretae a new type and add it a taxonomy field, attach this field to your taxo.

Create a content for this new type, selecting values for the taxonomy field.


Go to Taxonomy admin menu, edit the taxonomy and change its name.
Until this point all seems ok, and there is certainly an improvment because the terms seem to have follow the name change, but....

Go to your content and see that the taxonomy field has lost its value.
Go to the associated Content Type and see that its taxonomy field has lost it relation with your former taxonomy and not connected to the new one.
Moreover the Term contentype for the first taxonomy name is still there, there is also a new Term for the new name (but not propagated to the content type field).

And if you go in DB many weird things that would take a fastidious description.

sebastienros wrote Jul 12, 2013 at 7:59 PM

Fixed in changeset cce4911271a3

sfmskywalker wrote Mar 28 at 1:28 AM

Fixed in changeset a890164681f1747ce9ac780a518de2994626e900