We're updating the issue view to help you get more done. 

Foreign key constraint fails when creating a new list

Description

(reported initially via e-mail by matt goins):

I just noticed that when I create a new list in providence, then
delete it, I get a foreign key constraint error.

We're using providence from git, currently at revision:
fbcf6a9fe534edb375167dc4a4eeab63aac2babe

The install we're using was installed using an earlier version and then
updated recently.

Here are the steps to reproduce:

Create a list

  • Navigate to:
    Manage -> Lists and Vocabularies

  • Click "Add New List"

  • On the form, choose a Preferred Names and List Code, but leave
    everything else as the default.

  • Hit save.

Then delete the item:

  • Navigate to Manage -> Lists and Vocabularies

  • Find the list you created, on its form, hit delete.

Upon trying to delete, I get this error

/srv/ca0/providence/app/lib/core/Db/mysql.php:caPrintStacktrace@288
/srv/ca0/providence/app/lib/core/Db/DbStatement.phpb_mysql:execute@130
/srv/ca0/providence/app/lib/core/Db.phpbStatement:executeWithParamsAsArray@276
/srv/ca0/providence/app/lib/core/BaseModel.phpb:query@2928
/srv/ca0/providence/app/lib/core/BaseModelWithAttributes.php:BaseModel:delete@520
/srv/ca0/providence/app/lib/ca/BundlableLabelableBaseModelWithAttributes.php:BaseModelWithAttributes:delete@260
/srv/ca0/providence/app/lib/ca/BaseEditorController.php:BundlableLabelableBaseModelWithAttributes:delete@451
/srv/ca0/providence/app/lib/core/Controller/RequestDispatcher.php:BaseEditorControllerelete@215
/srv/ca0/providence/app/lib/core/Controller/AppController.php:RequestDispatcher:dispatch@112
/srv/ca0/providence/index.php:AppController:dispatch@103

DELETE FROM ca_lists WHERE list_id = 43Cannot delete or update a parent row: a foreign key constraint fails (`ca0`.`ca_list_items`, CONSTRAINT
`fk_ca_list_items_list_id` FOREIGN KEY (`list_id`) REFERENCES `ca_lists` (`list_id`))

This can be manually fixed by running these two queries after the fact.

DELETE FROM ca_list_item_labels WHERE item_id = (item_id of Root Node item)
DELETE FROM ca_list_items WHERE list_id = (list_id of list you were trying to delete)

Thanks for your help!

Environment

debian wheezy, collective access git master

Activity

Show:
User known
January 8, 2013, 1:01 AM

There's a fix for this in GitHub master. Let us know if this works for you. Thanks!

Assignee

User known

Reporter

Daniel Kahn Gillmor

Labels

None

Components

Priority

Minor
Configure