[TYPO3-mvc] Cannot update a 1:n relation [BUG FOUND]
Xavier Perseguers
typo3 at perseguers.ch
Thu Aug 12 12:01:24 CEST 2010
Hi,
Found where the problem is.
_isDiry('contact') always returns FALSE. I digged into the problem and
found where the test fails:
/**
* Checks the $value against the $cleanState.
*
* @param mixed $previousValue
* @param mixed $currentValue
* @return boolan
*/
protected function isPropertyDirty($previousValue, $currentValue) {
$result = FALSE;
// In case it is an object and it implements the
ObjectMonitoringInterface, we call _isDirty() instead of a simple
comparison of objects.
// We do this, because if the object itself contains a lazy loaded
property, the comparison of the objects might fail even if the object
didn't change
if (is_object($currentValue)) {
if ($currentValue instanceof
Tx_Extbase_Persistence_ObjectMonitoringInterface) {
$result = !is_object($previousValue) || $currentValue->_isDirty() ||
(get_class($previousValue) !== get_class($currentValue));
} else {
// For all other objects we do only a simple comparison (!=) as we
want cloned objects to return the same values.
$result = ($previousValue != $currentValue);
}
} else {
$result = ($previousValue !== $currentValue);
}
return $result;
}
Test goes into if ($currentValue instanceof
Tx_Extbase_Persistence_ObjectMonitoringInterface) but:
- previousValue is an object => isDirty = FALSE
- $currentValue is not dirty as the referenced object itself was not
modified => isDirty = FALSE
- both previous and current value have the same class!
As test, I deactivated this test to use the "For all other objects we do
only a simple comparison
After that, my relation is properly updated. Can someone from Extbase
team understands where the "real" error is?
Xavier
More information about the TYPO3-project-typo3v4mvc
mailing list