Project

General

Profile

Actions

Bug #86252

closed

Domain object doesn't get persisted correct

Added by Pixelant Developer about 6 years ago. Updated about 6 years ago.

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


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #86083: Cleanup parameter mismatchesClosedWouter Wolters2018-09-02

Actions
Actions #1

Updated by Daniel Gohlke about 6 years ago

  • Related to Task #86083: Cleanup parameter mismatches added
Actions #2

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.

Actions #3

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

Actions #4

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

Actions #5

Updated by Daniel Gohlke about 6 years ago

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

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF