Bug #86252

Domain object doesn't get persisted correct

Added by Pixelant Developer 2 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-09-14
Due date:
% Done:

100%

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)"?


Related issues

Related to TYPO3 Core - Task #86083: Cleanup parameter mismatches Closed 2018-09-02

Associated revisions

Revision c7b9b83d (diff)
Added by Daniel Lorenz 2 months ago

[BUGFIX] add propertyName to _isDirty() check

_isDirty() without the propertyName returns false if
propertyValue is an instance of DomainObjectInterface.

Resolves: #86252
Related: #86083
Releases: master
Change-Id: I3b916f6b3a416de6cd120bd1ff0bf5cfd0926445
Reviewed-on: https://review.typo3.org/58345
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

History

#1 Updated by Daniel Lorenz 2 months ago

  • Related to Task #86083: Cleanup parameter mismatches added

#2 Updated by Daniel Lorenz 2 months 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.

#3 Updated by Gerrit Code Review 2 months 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

#4 Updated by Gerrit Code Review 2 months 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

#5 Updated by Daniel Lorenz 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#6 Updated by Benni Mack about 2 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF