-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Delete all content throws error when subscriber is associated to a post #7875
Comments
https://github.com/TryGhost/Ghost/blob/master/core/server/api/db.js#L94 Replace this,
with this,
|
@vivekannan Thanks 👍 We would be happy about a PR, which 1. reproduces the error in a test and add's your fix on top to proof that it fixes this bug. |
OK. I am struggling to get the db integration test to create subscribers associated with a post so that the it fails during the deleteAllContent test. Also, how are posts properly deleted even with tags associated with them? Shouldn't it raise the same constraint error when deleting posts with subscribers? |
@vivekannan Did you run your test with MySQL?
|
Yes. I did run the test with NODE_ENV set to testing-mysql. However, the test passes as posts with subscribers are not created while testing the deleteAllContents API. So, I have to make changes to the test so that it creates dummy posts with subscribers. https://github.com/TryGhost/Ghost/blob/master/core/test/integration/api/api_db_spec.js The testUtils.setup doesn't create posts with subscribers. |
closes TryGhost#7875 - we need to delete the subscribers before deleting the posts
closes TryGhost#7875 - we need to delete the subscribers before deleting the posts
closes #7875 - we need to delete the subscribers before deleting the posts
closes #7875 - we need to delete the subscribers before deleting the posts
We have this same issue for trying to delete a single post when it has a subscriber tied to it, but not when trying to delete a subscriber (I'm sure we fixed that one, but can't find the issue). I have confirmed this on Ghost(Pro) blog today: Create post, subscribe from post:
Also, the fix implemented here for deleteAllContent is, IMO, the wrong fix. Delete all Content is meant to delete content = posts & tags. Deleting subscribers is unexpected behaviour IMO. In the alpha, we have removed the constraint that is causing these issues. So this issue is LTS only. |
I see 👍 Have scheduled it for the next LTS. |
refs TryGhost#7875 - do not delete subscribers if deleting all the content - ensure dropping all the content and deleteting a single post will delete the reference in the subscriber if exist
refs #7875 - do not delete subscribers if deleting all the content - ensure dropping all the content and deleteting a single post will delete the reference in the subscriber if exist
When trying to delete all content, we are getting a SQL error. Seems that deleting the content does't work if there is a subscriber associated with the post because of a constraint.
Important: This bug does not exist using sqlite.
Steps to Reproduce
Technical details:
The text was updated successfully, but these errors were encountered: