curationexperts / laevigata

A Hyrax-based ETD repository including deposit workflow
Other
5 stars 4 forks source link

Check whether deleting superuser causes errors #1102

Closed bess closed 6 years ago

bess commented 6 years ago

In our 1.x branch, deleting a superuser causes submissions errors such that newly submitted ETDs no longer go to the correct workflow (instead they get published immediately) and the user gets an error upon submission. Check to see whether this is still an issue in our 2.x branch.

If there is still a problem, fix it. If we can confirm that there is a problem in laevigata, open a ticket in Hyrax to try to reproduce in a base Hyrax app.

val99erie commented 6 years ago

@bess I'm not sure if you'll remember exactly how you deleted the user, but can you tell me whether you used user.delete or user.destroy or user.destroy! or some other method?

val99erie commented 6 years ago

I was able to reproduce this problem on master (SHA 098e707d7a88507f4fa4dfa8b1ff04d34643588f).

Without knowing exactly what ruby code was run to delete the user in the production environment, I can't be sure, but this is my best guess as to what happened...

If I delete the user with either user.destroy! or user.destroy, then the app works as expected:

But, if I delete the user by running user.delete, then I am able to reproduce the problem:

So, I am able to reproduce the problem on master, but I don't think this is a bug. If you run user.delete instead of user.destroy, no callbacks will be run, which will leave orphaned records in all the Sipity join tables. In that situation, I wouldn't expect the code to work properly.

My best guess is that delete was used to delete that superuser record in production. We'll need to use destroy or destroy! instead.

val99erie commented 6 years ago

@bess I'm going to re-assign this story to you for some follow-up.

Could you read my explanation above and see if that seems like the likely cause of the problem, and close the story if you are happy with that explanation.

If you think we should write a rake task or some other tool to delete users, could you write a story for that? (I'm not sure how common that is. Maybe we should just document it somewhere?)

bess commented 6 years ago

Yes, this fixes the problem, and I was able to destroy! the alicia user in production without incident (after testing it elsewhere first).