Actions
Bug #86252
closedDomain object doesn't get persisted correct
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-09-14
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
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)"?
Actions