denny / ShinyCMS

ShinyCMS is an open source CMS. This is the Perl version, built with Catalyst and DBIC. (There is also a Ruby on Rails version: www.github.com/denny/ShinyCMS-ruby)
56 stars 24 forks source link

Deleting user fails if outstanding confirmations exist #6

Closed denny closed 8 years ago

denny commented 12 years ago

See title... db constraint sort of fail.

wbraswell commented 9 years ago

@denny Is this the same error I get when I try to delete a user which still has posts they own? Such as attempting to delete the demo user "w1n5t0n" without first deleting w1n5t0n's posts?

[error] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails ("shac_seascouts_website"."news_item", CONSTRAINT "news_item_fk_author" FOREIGN KEY ("author") REFERENCES "user" ("id")) [for Statement "DELETE FROM user WHERE ( id = ? )" with ParamValues: 0='2'] at /home/wbraswell/public_html/shac_seascouts_website-latest/script/../lib/ShinyCMS/Controller/Admin/User.pm line 204

denny commented 9 years ago

Yeah, there's quite a lot of work that could be done still on either deleting related content when you delete a parent item, or flagging it up for user decision on whether they want to go and delete that stuff.

That said, I thought I'd done the confirmations one. I'll look at it again.

wbraswell commented 9 years ago

This is still an issue, now it's doing it the IP address logging as well:

FastCGI: server "/tmp/burksdigital.biz.fcgi" stderr: [error] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails ("burksdigital_biz"."user_ip_address", CONSTRAINT "user_ip_address_fk_user" FOREIGN KEY ("user") REFERENCES "user" ("id")) [for Statement "DELETE FROM user WHERE ( id = ? )" with ParamValues: 0='5'] at /home/wbraswell/public_html/burksdigital.biz-latest/script/../lib/ShinyCMS/Controller/Admin/User.pm line 205, referer: http://burksdigital.biz/admin/user/edit/5

denny commented 8 years ago

Just pushed a commit which hopefully removes all but the non-trivial user-generated content and associated metadata before attempting to delete a user account. Still need to decide what to do about the non-trivial stuff - blog posts, transaction logs, etc.

wbraswell commented 8 years ago

Nice, will test on my next Shiny install. :+1: