trashed cards of deleted type bust upon fetch

Ticket

+commit
 

If there is a trashed card Sample Blech of type Blech and you then delete the Blech type, that trashed card still has "Blech" as the type.  Since Blech is no longer instantiated (assuming the server gets restarted!), when you go to Sample Blech (to recreate, say, or because of an old link), wagn explodes.

 

In the long term, I'm not sure we want to depend on this railsy type inheritance stuff in the first place.  Would rather treat all sets (*type, *right, etc) equally.

 

In the medium term, we may be able to add something to before_destroy to change the types of all the trashed cards.  That may involve building new api to operate on trashed cards, but that's probably desirable.

 

In the very short term, here's a SQL workaround for sites that are having this problem:

 update cards set type='Basic' where id in (select c.id from cards c left join cardtypes ct on c.type = ct.class_name where ct.class_name is null);

 

 

 

 

Thought I'd set up a test for this, and I'm not seeing the behavior you describe.

 

http://test.dwagn.org/wagn/trashed_cards_of_deleted_type_bust_upon_fetch

 

http://test.dwagn.org/wagn/Sample_Blech


Regarding your medium-term solution, I thought that if we change the type of cards being deleted, then they won't have the right type when they're recreated, but I tested current behavior, and cards recreated from trash seem to be Basic. Seems like they ought to be the type they were, yes? Ticket?

 

I ran into a series of other problems, ticketing separately.

  --John Abbe.....Thu Nov 18 11:36:59 -0800 2010


When you recreate a card, it should act like an entirely new card with whatever default type and content you would normally get trying to create a card of that name. (So, usually, Basic is exactly right) The only difference is in the changes log. Otherwise it will be entirely baffling for whatever user happens to try to create something of a name that happened to be in the trash if they're just trying to create a new card and it bizarrely happens to be a company or a fruit or something.

 

As for not seeing the behavior, it may be a caching issue. Good idea to try to recreate it on test.dwagn.org, though. I used the workaround to fix the problems I was seeing on connectipedia.org

  --Ethan McCutchen.....Thu Nov 18 12:14:26 -0800 2010


oh, yeah, I guess the ruby constant for the deleted type sticks around unless you restart the server after the deletes. I've got the problem reproduced now: http://test.dwagn.org/wagn/Sample_Blech3

  --Ethan McCutchen.....Thu Nov 18 12:28:17 -0800 2010


by the way, wrt to your comment about recreating the type of trashed cards, I'm guessing that you're probably coming from a place of wanting to do a full reversion from trash. I want that, too, and I think that will probably need to be done through a different route than just creating a new card with the same name. Part of that will entail tracking card type changes in a log as well as content (and we want to do name changes, too).

 

But I'm pretty confident we don't want to preserve type or (current) content when we pull stuff out in most circumstances -- it used to behave that way and led to all sorts of baffledness :)

  --Ethan McCutchen.....Thu Nov 18 12:31:50 -0800 2010


Makes sense.

 

Yeah, dunno when we'll overhaul card history, but it will be nice.

  --John Abbe.....Thu Nov 18 15:15:41 -0800 2010


I think this was actually fixed in Wagn 1.7, but can test now.

  --Ethan McCutchen.....Tue Nov 29 10:22:08 -0800 2011


Tested the existing example, and from scratch. No problem, closing.

  --John Abbe.....Sun Dec 11 10:34:25 -0800 2011