mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 02:21:55 -04:00
Clean up unused Tags, LocSubjects, and Collections
On `Ebook::Save()` and `Ebook::Delete()`, remove any unreferenced `Tag`, `LocSubject`, and `Collection` records. These are analogous to these lines in `Ebook::Create()`: ``` $this->CreateTags(); $this->CreateLocSubjects(); $this->CreateCollections(); ``` `EbookPlaceholder`s can't have `Tags` or `LocSubjects` at the moment, but other mistakes in production that are later corrected could leave unused `Tags` and `LocSubjects`. Context: https://github.com/standardebooks/web/pull/447#issuecomment-2555734692
This commit is contained in:
parent
88ed9639f5
commit
d6dd10be9c
4 changed files with 44 additions and 0 deletions
|
@ -1984,6 +1984,10 @@ final class Ebook{
|
|||
|
||||
$this->RemoveEbookPlaceholder();
|
||||
$this->AddEbookPlaceholder();
|
||||
|
||||
EbookTag::DeleteUnused();
|
||||
LocSubject::DeleteUnused();
|
||||
Collection::DeleteUnused();
|
||||
}
|
||||
catch(Exceptions\ValidationException $ex){
|
||||
$error = new Exceptions\InvalidEbookException();
|
||||
|
@ -2176,6 +2180,10 @@ final class Ebook{
|
|||
$this->RemoveTocEntries();
|
||||
$this->RemoveEbookPlaceholder();
|
||||
|
||||
EbookTag::DeleteUnused();
|
||||
LocSubject::DeleteUnused();
|
||||
Collection::DeleteUnused();
|
||||
|
||||
foreach($this->Projects as $project){
|
||||
$project->Delete();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue