Can't delete site in Omeka-S


#1

In a brand-new install, with only two sites added, and otherwise empty except for installed modules, when I try to delete one of the sites I get the following " ForeignKeyConstraintViolationException":

 Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException
An exception occurred while executing 'DELETE FROM site WHERE id = ?' with params [2]: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cvlsites_devill`.`site_page`, CONSTRAINT `FK_2F900BD9F6BD1646` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`))

Details:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cvlsites_devill`.`site_page`, CONSTRAINT `FK_2F900BD9F6BD1646` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`)) in /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105
Stack trace:
#0 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(105): PDOStatement->execute(NULL)
#1 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1006): Doctrine\DBAL\Driver\PDOStatement->execute()
#2 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(596): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM sit...', Array, Array)
#3 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(580): Doctrine\DBAL\Connection->delete('site', Array, Array)
#4 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1094): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->delete(Object(Omeka\Entity\Site))
#5 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(406): Doctrine\ORM\UnitOfWork->executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#6 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(356): Doctrine\ORM\UnitOfWork->commit(NULL)
#7 /var/www/dev/devill/application/src/Api/Adapter/AbstractEntityAdapter.php(425): Doctrine\ORM\EntityManager->flush()
#8 /var/www/dev/devill/application/src/Api/Manager.php(239): Omeka\Api\Adapter\AbstractEntityAdapter->delete(Object(Omeka\Api\Request))
#9 /var/www/dev/devill/application/src/Api/Manager.php(164): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#10 /var/www/dev/devill/application/src/Mvc/Controller/Plugin/Api.php(189): Omeka\Api\Manager->delete('sites', Array, Array, Array)
#11 /var/www/dev/devill/application/src/Controller/SiteAdmin/IndexController.php(416): Omeka\Mvc\Controller\Plugin\Api->delete('sites', Array)
#12 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Omeka\Controller\SiteAdmin\IndexController->deleteAction()
#13 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#14 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#15 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(106): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#16 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/DispatchListener.php(138): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#17 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#18 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#19 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#20 /var/www/dev/devill/index.php(21): Zend\Mvc\Application->run()
#21 {main}

Next Doctrine\DBAL\Driver\PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cvlsites_devill`.`site_page`, CONSTRAINT `FK_2F900BD9F6BD1646` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`)) in /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107
Stack trace:
#0 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1006): Doctrine\DBAL\Driver\PDOStatement->execute()
#1 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(596): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM sit...', Array, Array)
#2 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(580): Doctrine\DBAL\Connection->delete('site', Array, Array)
#3 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1094): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->delete(Object(Omeka\Entity\Site))
#4 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(406): Doctrine\ORM\UnitOfWork->executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#5 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(356): Doctrine\ORM\UnitOfWork->commit(NULL)
#6 /var/www/dev/devill/application/src/Api/Adapter/AbstractEntityAdapter.php(425): Doctrine\ORM\EntityManager->flush()
#7 /var/www/dev/devill/application/src/Api/Manager.php(239): Omeka\Api\Adapter\AbstractEntityAdapter->delete(Object(Omeka\Api\Request))
#8 /var/www/dev/devill/application/src/Api/Manager.php(164): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#9 /var/www/dev/devill/application/src/Mvc/Controller/Plugin/Api.php(189): Omeka\Api\Manager->delete('sites', Array, Array, Array)
#10 /var/www/dev/devill/application/src/Controller/SiteAdmin/IndexController.php(416): Omeka\Mvc\Controller\Plugin\Api->delete('sites', Array)
#11 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Omeka\Controller\SiteAdmin\IndexController->deleteAction()
#12 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#14 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(106): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#15 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/DispatchListener.php(138): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#16 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#17 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#18 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#19 /var/www/dev/devill/index.php(21): Zend\Mvc\Application->run()
#20 {main}

Next Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing 'DELETE FROM site WHERE id = ?' with params [2]:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`cvlsites_devill`.`site_page`, CONSTRAINT `FK_2F900BD9F6BD1646` FOREIGN KEY (`site_id`) REFERENCES `site` (`id`)) in /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:60
Stack trace:
#0 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(128): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
#1 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1015): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'DELETE FROM sit...', Array)
#2 /var/www/dev/devill/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(596): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM sit...', Array, Array)
#3 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(580): Doctrine\DBAL\Connection->delete('site', Array, Array)
#4 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1094): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->delete(Object(Omeka\Entity\Site))
#5 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(406): Doctrine\ORM\UnitOfWork->executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#6 /var/www/dev/devill/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(356): Doctrine\ORM\UnitOfWork->commit(NULL)
#7 /var/www/dev/devill/application/src/Api/Adapter/AbstractEntityAdapter.php(425): Doctrine\ORM\EntityManager->flush()
#8 /var/www/dev/devill/application/src/Api/Manager.php(239): Omeka\Api\Adapter\AbstractEntityAdapter->delete(Object(Omeka\Api\Request))
#9 /var/www/dev/devill/application/src/Api/Manager.php(164): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#10 /var/www/dev/devill/application/src/Mvc/Controller/Plugin/Api.php(189): Omeka\Api\Manager->delete('sites', Array, Array, Array)
#11 /var/www/dev/devill/application/src/Controller/SiteAdmin/IndexController.php(416): Omeka\Mvc\Controller\Plugin\Api->delete('sites', Array)
#12 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Omeka\Controller\SiteAdmin\IndexController->deleteAction()
#13 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#14 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#15 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(106): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#16 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/DispatchListener.php(138): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#17 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#18 /var/www/dev/devill/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#19 /var/www/dev/devill/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#20 /var/www/dev/devill/index.php(21): Zend\Mvc\Application->run()

#2

This is strange, because Doctrine (our database layer) should be handling deleting the associated pages and blocks for you when deleting a site. I can’t reproduce your problem.

If you manually delete the pages for the site individually does that resolve the issue?


#3

I can delete items with no problem. The site has no pages or items. I get the same error when trying to delete it from the Site Info panel (/admin/site/s/panoramas) and from the Sites admin page (/admin/sites). And it’s not just that site–no site, once created, can be deleted.


#4

The site has no pages? Sites are created with a default page.


#5

Ah–sorry! I had not created any pages, so assumed there were none. Once I deleted the Welcome page I could delete the site.


#6

Well that’s good to hear, but it should still not be happening…

Can you share the data from the “System information” screen in your install? (It’s linked in the footer of the admin).


#7

Here you go.

Omeka S
Version 	1.4.0
PHP
Version 	7.0.33-0ubuntu0.16.04.5
SAPI 	apache2handler
Memory Limit 	512M
POST Size Limit 	16M
File Upload Limit 	16M
Garbage Collection 	Yes
Extensions 	apache2handler, apcu, calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imagick, imap, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, Phar, posix, readline, Reflection, session, shmop, SimpleXML, sockets, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zlib
Disabled Functions 	, pcntl_alarm, pcntl_exec, pcntl_fork, pcntl_getpriority, pcntl_get_last_error, pcntl_setpriority, pcntl_signal, pcntl_signal_dispatch, pcntl_sigprocmask, pcntl_sigtimedwait, pcntl_sigwaitinfo, pcntl_strerror, pcntl_wait, pcntl_waitpid, pcntl_wexitstatus, pcntl_wifcontinued, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifstopped, pcntl_wstopsig, pcntl_wtermsig
MySQL
Server Version 	5.7.26-0ubuntu0.16.04.1
Client Version 	mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
Mode 	ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
OS
Version 	Linux 4.4.0-154-generic x86_64