mysociety / fms-endpoint

basic problem-reports database and Open311 server, suitable for use with http://fixmystreet.org
Other
14 stars 29 forks source link

Creation of Category permitted without a Category ID, however can't then Edit or Delete Category #15

Closed andrewperry closed 12 years ago

andrewperry commented 12 years ago

You can create a new category at /index.php/admin/categories/add without specifying a category id, however if you do, you can't then edit or delete the new category as you get the error:

Fatal error: Uncaught exception 'Exception' with message 'On the state "edit" the Primary key cannot be null' in /home/fms-endpoint/codeigniter/fms_endpoint/libraries/grocery_crud.php:2312 Stack trace: #0 /home/fms-endpoint/codeigniter/fms_endpoint/libraries/grocery_crud.php(3159): grocery_CRUD_States->getStateInfo() #1 /home/fms-endpoint/codeigniter/fms_endpoint/controllers/admin.php(92): grocery_CRUD->render() #2 [internal function]: Admin->categories('edit') #3 /home/fms-endpoint/codeigniter/codeigniter/CodeIgniter.php(236): call_user_func_array(Array, Array) #4 /home/fms-endpoint/web/index.php(117): require_once('/home/open311/f...') #5 {main} thrown in /home/fms-endpoint/codeigniter/fms_endpoint/libraries/grocery_crud.php on line 2312

Leaving the entry there will then cause problems out in the world such as in FMS where running ./bin/open311-populate-service-list will give the error:

DBIx::Class::ResultSet::create(): [SQL::Abstract::ANON] Warning: HASH ref as bind value in insert is not supported at /home/fmsalpha/fixmystreet/bin/../perllib/Open311/PopulateServiceList.pm line 158 Failed to create contact for service code HASH(0x74bcda0) for council 58: Cannot bind a reference

I will file this over on FMS as another issue, since FMS should handle bad Open311 servers gracefully.

andrewperry commented 12 years ago

Please see our pull request for the issue on the fms-endpoint end.