Bug #86252
closedDomain object doesn't get persisted correct
100%
Description
After I create new domain object, set all properties values, then persist, field where i assigned child domain object doesn't get updated.
Example code:
$userAnswer = $this->objectManager->get(UserAnswer::class);
$question = $this->objectManager->get(QuestionRepository::class)->findByUid(1);
$userAnswer->setQuestion($question);
$userAnswer->setPid($question->getPid());
$this->objectManager->get(PersistenceManager::class)->persistAll();
And my "question" object is not attached to "user answer", field in DB remains to be zero.
In my TCA configuration file "tx_pxasurvey_domain_model_useranswer.php" i have field configuration:
'question' => [
'exclude' => true,
'label' => $ll . 'tx_pxasurvey_domain_model_useranswer.question',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_pxasurvey_domain_model_question',
'foreign_table_where' => 'AND tx_pxasurvey_domain_model_question.deleted=0',
'size' => 1,
'maxitems' => 1
],
],
In "ext_tables.sql" "question int(11) unsigned DEFAULT '0'"
In model "UserAnswer.php"
/**
* question
*
* @var \Pixelant\PxaSurvey\Domain\Model\Question
*/
protected $question = null;
After investigation, I find out that this might be caused by "_isDirty()" check in "\TYPO3\CMS\Extbase\Persistence\Generic\Backend" on line "397", where it returns "false".
Does it missing check with property name "$object->_isDirty($propertyName)"?
Updated by Daniel Gohlke about 6 years ago
- Related to Task #86083: Cleanup parameter mismatches added
Updated by Daniel Gohlke about 6 years ago
I think this error is caused by this change: https://review.typo3.org/#/c/58123/2/typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php
Adding the $propertyName to _isDirty() saves the question property to the new $userAnswer object.
Updated by Gerrit Code Review about 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58345
Updated by Gerrit Code Review about 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58345
Updated by Daniel Gohlke about 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset c7b9b83d5239418725c7867482d50cfdb92ce8bf.