Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When deleting a collection delete its related data thoroughly #3889

Conversation

arthurperton
Copy link
Contributor

@arthurperton arthurperton commented Jun 22, 2021

Fixes #3848 and #3890.

  • Deletes entry localizations, if any
  • Deletes the trees, if any

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love if #3891 could be combined with this PR. As I mentioned there, it's such similar stuff happening right next to the other, I feel like it'd be better tested together.

You could rename the PR to something like "ensure related items are deleted when deleting a collection".

@arthurperton arthurperton changed the title When deleting a collection delete its tree(s) too When deleting a collection delete its related data thoroughly Jun 22, 2021
@arthurperton
Copy link
Contributor Author

Yeah totally, I found the one issue while solving the other. The fixes are combined now into this PR.

@arthurperton
Copy link
Contributor Author

@jasonvarga I wonder what you mean in this comment. What is it that needs doing?

@jasonvarga
Copy link
Member

I think I just meant once it was merged.

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error when I delete the collection when using multisite.

[2021-07-14 22:48:04] local.ERROR: Call to a member function pages() on null {"userId":"3ad6235d-8556-42dd-a500-9d7cc1373bd0","exception":"[object] (Error(code: 0): Call to a member function pages() on null at /users/jason/code/statamic/three/cms/src/Entries/Entry.php:167)
[stacktrace]
#0 /Users/jason/Code/statamic/three/sandbox/vendor/laravel/framework/src/Illuminate/Support/helpers.php(263): Statamic\\Entries\\Entry->Statamic\\Entries\\{closure}(Object(Statamic\\Structures\\CollectionTree))
#1 /users/jason/code/statamic/three/cms/src/Entries/Entry.php(171): tap(Object(Statamic\\Structures\\CollectionTree), Object(Closure))
#2 /Users/jason/Code/statamic/three/sandbox/vendor/laravel/framework/src/Illuminate/Support/helpers.php(263): Statamic\\Entries\\Entry->Statamic\\Entries\\{closure}(Object(Statamic\\Structures\\CollectionStructure))
#3 /users/jason/code/statamic/three/cms/src/Entries/Entry.php(172): tap(Object(Statamic\\Structures\\CollectionStructure), Object(Closure))
#4 /users/jason/code/statamic/three/cms/src/Entries/Collection.php(605): Statamic\\Entries\\Entry->delete()
#5 /Users/jason/Code/statamic/three/sandbox/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(235): Statamic\\Entries\\Collection->Statamic\\Entries\\{closure}(Object(Statamic\\Entries\\Entry), 2)
#6 /users/jason/code/statamic/three/cms/src/Entries/Collection.php(606): Illuminate\\Support\\Collection->each(Object(Closure))

@arthurperton
Copy link
Contributor Author

Thanks I'll check that.

@arthurperton arthurperton marked this pull request as draft July 17, 2021 09:18
@arthurperton
Copy link
Contributor Author

I get an error when I delete the collection when using multisite.

The last commit fixes the error. But when using multisite, the tree files are not deleted (well actually they are, but the get created again) and remain with { } inside. So this still needs some work.

@arthurperton arthurperton changed the base branch from 3.1 to 3.2 August 25, 2021 17:38
@jasonvarga jasonvarga removed the bug label Nov 23, 2021
@jasonvarga
Copy link
Member

Closing as this has been sitting as a draft for a while. Feel free to reopen when it's ready or there's a better solution. Thanks!

@jasonvarga jasonvarga closed this Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collection tree file not deleted when collection deleted
4 participants