agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.39k stars 523 forks source link

fix (removeSingleton): remove singleton key also from DB #1460

Closed abernh closed 2 years ago

abernh commented 2 years ago

Bug

Removing a singleton currently only removes the "singleton spec" file but not its fields data in the DB.

This causes old entries to repopulate a singleton after it was deleted and re-created with the same name and fields.

See also the discussion here https://discourse.getcockpit.com/t/entries-deleted-inside-cockpit-are-retained-in-api/1941/2?u=abernh

Expected behavior

deleting a singleton should also delete all its data and re-creating it with the same fields should not show the old values of the previous singleton

Fix

Calling ->storage->removeKey() on the singleton on-remove solves the issue.

aheinze commented 2 years ago

Thanks!