cos-archives / archival-project

Open Science Collaboration Archival Project
1 stars 3 forks source link

cannot delete a paper #16

Open jlcohoon opened 9 years ago

jlcohoon commented 9 years ago

From my dashboard, when viewing the list of papers, I noticed that one paper's DOI was pointing to the wrong URL (archivalproject.org/papers/XXXX rather than dx.doi.org/XXXX). I tried to delete the paper to re-add it, but an error occurred. A few moments before, the same incorrect URL problem occurred but I successfully deleted the paper. I was following the same steps this time to delete, but encountered an internal error.

rubenarslan commented 9 years ago

The error only occurs if a URL is missing, which should only happen if someone manually adds a study to the DB. However the internal error when deleting the study is due to the study being coded already (basically it has children and when deleting we don't want to leave orphans).

Error: [PDOException] SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`archival`.`codedpapers`, CONSTRAINT `fk_codedpapers_papers` FOREIGN KEY (`paper_id`) REFERENCES `papers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
#0 /var/www/lib/Cake/Model/Datasource/DboSource.php(459): PDOStatement->execute(Array)
#1 /var/www/lib/Cake/Model/Datasource/DboSource.php(425): DboSource->_execute('DELETE `Paper` ...', Array)
#2 /var/www/lib/Cake/Model/Datasource/Database/Mysql.php(400): DboSource->execute('DELETE `Paper` ...')
#3 /var/www/lib/Cake/Model/Model.php(2382): Mysql->delete(Object(Paper), Array)
#4 /var/www/app/Controller/PapersController.php(156): Model->delete()
#5 [internal function]: PapersController->delete('126')
#6 /var/www/lib/Cake/Controller/Controller.php(485): ReflectionMethod->invokeArgs(Object(PapersController), Array)
#7 /var/www/lib/Cake/Routing/Dispatcher.php(186): Controller->invokeAction(Object(CakeRequest))
#8 /var/www/lib/Cake/Routing/Dispatcher.php(161): Dispatcher->_invoke(Object(PapersController), Object(CakeRequest), Object(CakeResponse))
#9 /var/www/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#10 {main}

So we should change the foreign key to automatically kill any children too, or, my preference: give a better error message.. Also, at the moment there is no way to find the codedpapers from the paper view, I had to go via the user view. That should be changed.