Bug #34448
Integrity constraint violation on FLOW3 resource tables
Status: | Resolved | Start date: | 2012-03-01 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
Category: | Persistence | |||
Target version: | - | |||
PHP Version: | 5.3 | Complexity: | ||
Has patch: | No | Affected Flow version: | FLOW3 1.0.3 |
Description
I have an own model/class/controller, called "award" with a property mapped to the standard FLOW3 resource table.
/**
* The image
* @var \TYPO3\FLOW3\Resource\Resource
* @ORM\ManyToOne(targetEntity="\TYPO3\FLOW3\Resource\Resource")
*/
protected $image;
This works fine, the images get uploaded and the resource and resourcepointer tables are correctly filled. Then I created two of my award models and uploaded the same image for every one. Still all works fine, the resourcepointer table stays with only one entry and the resource table filled up with the same 'resourcepointer'-field for every record.
The error occurs when I try to delete my award-object. It seems FLOW3 tries to delete the only record of the resourcepointer table even though there still exist references from my other award-object.
This naturally fails and the following error pops up:
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`praemien`.`typo3_flow3_resource_resource`, CONSTRAINT `typo3_flow3_resource_resource_ibfk_1` FOREIGN KEY (`resourcepointer`) REFERENCES `typo3_flow3_resource_resourcepointer` (`hash`) 13 PDOStatement::execute(array) 12 Doctrine\DBAL\Connection::executeUpdate("DELETE FROM typo3_flow3_resource_resourcepointer WHERE hash = ?", array) 11 Doctrine\DBAL\Connection::delete("typo3_flow3_resource_resourcepointer", array) 10 Doctrine\ORM\Persisters\BasicEntityPersister::delete(TYPO3\FLOW3\Persistence\Doctrine\Proxies\TYPO3FLOW3ResourceResourcePointerProxy) 9 Doctrine\ORM\UnitOfWork::executeDeletions(TYPO3\FLOW3\Persistence\Doctrine\Mapping\ClassMetadata) 8 Doctrine\ORM\UnitOfWork::commit() 7 Doctrine\ORM\EntityManager::flush() 6 TYPO3\FLOW3\Persistence\Doctrine\PersistenceManager_Original::persistAll("TYPO3\FLOW3\Core\Bootstrap::finishedRuntimeRun") 5 call_user_func_array(array, array) 4 TYPO3\FLOW3\SignalSlot\Dispatcher::dispatch("TYPO3\FLOW3\Core\Bootstrap", "finishedRuntimeRun", array) 3 TYPO3\FLOW3\Core\Bootstrap::emitFinishedRuntimeRun() 2 TYPO3\FLOW3\Core\Bootstrap::handleWebRequest() 1 TYPO3\FLOW3\Core\Bootstrap::run()
Associated revisions
[BUGFIX] Integrity constraint violation deleting resources
If you have two resources using the same resource pointer,
deleting a Resource will trigger deletion of the
connected ResourcePointer which then leads to an integrity
constraint violation.
This patch tells doctrine NOT to cascade delete operations.
This will lead to orphan resource-pointers which have to
be deleted manually or on a regular base.
Change-Id: I3c98bfc603d5093af96b991e26b9eff3b2f5c840
Fixes: #34448
Releases: 1.1, 1.2
[BUGFIX] Integrity constraint violation deleting resources
If you have two resources using the same resource pointer,
deleting a Resource will trigger deletion of the
connected ResourcePointer which then leads to an integrity
constraint violation.
This patch tells doctrine NOT to cascade delete operations.
This will lead to orphan resource-pointers which have to
be deleted manually or on a regular base.
Change-Id: I3c98bfc603d5093af96b991e26b9eff3b2f5c840
Fixes: #34448
Releases: 1.1, 1.2
History
#1 Updated by Karsten Dambekalns over 3 years ago
- Category changed from - Error Handler Report - to Persistence
- Status changed from New to Accepted
- Assigned To set to Karsten Dambekalns
#2 Updated by Gerrit Code Review over 3 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/10137
#3 Updated by Gerrit Code Review over 3 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/10137
#4 Updated by Gerrit Code Review about 3 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/10137
#5 Updated by Gerrit Code Review about 3 years ago
Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/11800
#6 Updated by Ferdinand Kuhl about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8b383f621e0c3a91a39d13b5b677476d71c24d2d.