Bug 17387

Summary: Add an undelete feature for items/biblios
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: CatalogingAssignee: Galen Charlton <gmcharlt>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, caroline.cyr-la-rose, clemens.tubach, davewood, dcook, enica, george, hacheng, hammat.wele, jbalway, josef.moravec, kebliss, laura, lisette, m.de.rooy, michaela.sieber, mnero, mspinney, nick, olli-antti.kivilahti, philippe.blouin, rcoert, rocio, severine.queune, tmisilo
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Nick Clemens (kidclamp) 2016-09-30 21:01:34 UTC
Some libraries would like to be able to restore items accidentally deleted. 

This should be possible, rows can be copied over as long as there are checks in place for unique ids.
Comment 1 George Williams (NEKLS) 2017-12-01 21:03:43 UTC
This is a great idea.
Comment 2 Rocio Dressler 2018-04-05 17:47:56 UTC
Agreed! I've heard interest in this feature from other libraries.
Comment 3 davewood 2023-04-14 09:22:21 UTC
I have written this code already and would like to add the feature.
Comment 4 David Cook 2023-04-16 23:57:32 UTC
(In reply to davewood from comment #3)
> I have written this code already and would like to add the feature.

If you haven't already, take a look at the following:

https://koha-community.org/get-involved/for-developers/

If you need help attaching patches, I'd suggest hopping on IRC or the Koha Developers List: https://koha-community.org/support/
Comment 5 Katrin Fischer 2023-06-30 08:28:58 UTC
We'd be also interested in this. Items seem a little less complicated, maybe they would make a good starting point.
Comment 6 Katrin Fischer 2023-06-30 17:12:35 UTC
*** Bug 13556 has been marked as a duplicate of this bug. ***
Comment 7 Michaela Sieber 2024-08-27 11:19:13 UTC
Yes, this should be a core feature!

Maybe the InLibro Plugin is a good start ?

https://github.com/inLibro/koha-plugin-undelete-records
Comment 8 David Cook 2024-09-04 23:48:32 UTC
(In reply to Michaela Sieber from comment #7)
> Yes, this should be a core feature!
> 
> Maybe the InLibro Plugin is a good start ?
> 
> https://github.com/inLibro/koha-plugin-undelete-records

I ended up using this as inspiration for a pure SQL undelete for 1 bib record (and attached items) I needed to undelete. 

I should look at biblio_metadata again, as it seems that the ID wasn't able to be restored. Had to use a new ID... which is reminiscent of that autoincrement bug. Hmm... it was an old database. (I noticed the InLibro code also gets a new ID for restoring biblio_metadata, so must be a more common issue?)
Comment 9 David Cook 2024-09-04 23:50:14 UTC
Of course, "undelete" only works for the bib record and items themselves. Other tables using foreign keys will have cascading deletes. So the data in the "linktracker" table for instance cannot be restored. It's permanently deleted. 

Given how many people seem to accidentally delete things... I reckon that soft delete feature would be handy. (Of course, it would be a mountain of work to refactor Koha to handle soft deletes...)
Comment 10 Enica Davis 2024-10-10 14:03:07 UTC
Plug-in for InLibro also doesn't work for 24.05. :(

We are still getting a lot of request about this from libraries.
Comment 11 Joseph Alway 2025-02-27 21:46:49 UTC
Some sort of undelete function would be great. However, I can just pull the record from an old backup of our catalog. Thankfully I've not needed to do this very often.