If lang is something else than 0, delete of last lang content doesn't set metadata_deleted to 1 but instead throws the last _i row away.
This leaves the database into inconsistent state because the actual main table row is still there with metadata_deleted=0 but all _i rows are all gone. The object is basically gone (last instance of it was deleted after all) but its table still has a row claiming the object exists (when it actually was deleted). Clearly that's not correct. When object is gone, metadata_deleted should also be set to 1.
This also affects the end user: Asgard's trash can can't be used to restore the delete. (Which is expected as now single lang object deletes can't be restored if lang is something else than 0.)
I think I know how this should be fixed. See:
http://trac.midgard-project.org/browser/branches/ragnaroek/midgard/core/midgard/src/types.c?rev=24638#L2822
The skipping of lang0 rows when counting the _i table rows should be removed. Then the _i row should be deleted if there are multiple rows. See:
http://trac.midgard-project.org/browser/branches/ragnaroek/midgard/core/midgard/src/types.c?rev=24638#L2841
"lang_i > 0" should be "lang_i > 1" then.
If done that way, the delete for last lang content would result _i row to stay there and metadata_deleted to be set to 1 instead. Which would be the correct way to handle this I think. Clearly metadata_deleted should be 1 when object is gone.
I'm setting this to critical because the database inconsistency effect makes this a bit ugly. It is hard to clean the database afterwards...