Bug #26365
Importing resources causes integrity constraint violation: 1062 Duplicate entry
| Status: | Resolved | Start date: | 2011-04-27 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assigned To: | Sebastian Kurfuerst | % Done: | 100% |
|
| Category: | Resource | |||
| Target version: | TYPO3 Flow Base Distribution - 1.0 beta 1 | |||
| PHP Version: | Complexity: | |||
| Has patch: | Affected Flow version: |
Description
Example
$flagResource = $this->resourceManager->importResource('resource://Tutorials/Public/Images/Icons/Germany.png');
$languageModel = $this->objectManager->create('F3\Tutorials\Domain\Model\Language');
$languageModel->setName('German');
$languageModel->setImage($flagResource);
$this->languageRepository->add($languageModel);
and than
$this->languageRepository->removeAll();
Problem:
the hash in the flow3_resource_resourcepointer doesnt delete
if i add the language again
$flagResource = $this->resourceManager->importResource('resource://Tutorials/Public/Images/Icons/Germany.png');
$languageModel = $this->objectManager->create('F3\Tutorials\Domain\Model\Language');
$languageModel->setName('German');
$languageModel->setImage($flagResource);
$this->languageRepository->add($languageModel);
an uncaught exception throws
#23000: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3bed18a6e887a13c69c7f17ef7a00bfaead3ba8d' for key 'PRIMARY'
This is the model
/**
* A tutorial language
*
* @package Tutorials
* @subpackage Domain/Model
* @scope prototype
* @entity
*/
class Language {
/**
* @var string
* @validate Alphanumeric, StringLength(minimum = 1, maximum = 20)
*/
protected $name;
/**
* @var \F3\FLOW3\Resource\Resource
* @ManyToOne(cascade={"all"})
* validate NotEmpty
*/
protected $image;
/**
* Sets the languages name
*
* @param string $name
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Returns the languages name
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Sets the original resource
*
* @param \F3\FLOW3\Resource\Resource $originalResource
* @return void
*/
public function setImage(\F3\FLOW3\Resource\Resource $image) {
$this->image = $image;
}
/**
* Returns the original resource
*
* @return \F3\FLOW3\Resource\Resource $image
*/
public function getImage() {
return $this->image;
}
}
History
#1 Updated by Karsten Dambekalns about 4 years ago
- Subject changed from Persistence: Integrity constraint violation: 1062 Duplicate entry to Importing resources causes integrity constraint violation: 1062 Duplicate entry
- Category changed from Persistence to Resource
- Status changed from New to Resolved
- Assigned To set to Sebastian Kurfuerst
- Target version set to 1.0 beta 1
- % Done changed from 0 to 100
Solved with https://review.typo3.org/#change,2222