I'm back hunting bugs :-)
Can you tell me what the function of the storage_category_id is? Should it be the first category where a photo is uploaded - and dissociating this category should not be possible?
I found the remark:
// physical links must not be broken, so we must first retrieve image_id
// which create virtual links with the category to "dissociate from".
I find almost no image in the database with a storage_category_id and I _can_ dissociate them from all categories and so delete them by accident! :-(
And what are physical links? Do they still exist? Or are they the relict of an old version?
storage_category_id is the category ID in case of a manual upload in the "galleries" folder, so with physical categories
if you only use virtual categories, it's always null