[TYPO3-mvc] BUG in Backend.php READ THIS ONE

Michael Knoll mimi at kaktusteam.de
Thu Sep 16 15:08:39 CEST 2010


Hi there,

I sent the wrong snippet before... here is the method in Backend.php 
where the problem occurs:


	/**
	 * Returns a table row to be inserted or updated in the database
	 *
	 * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The 
appropriate data map representing a database table
	 * @param array $properties The properties of the object
	 * @return array A single row to be inserted in the database
	 */
	protected function 
addCommonFieldsToRow(Tx_Extbase_DomainObject_DomainObjectInterface 
$object, array &$row) {
		$className = get_class($object);
		$dataMap = $this->dataMapper->getDataMap($className);
		if ($object->_isNew() && ($dataMap->getCreationDateColumnName() !== 
NULL)) {
			$row[$dataMap->getCreationDateColumnName()] = $GLOBALS['EXEC_TIME'];
		}
		if ($dataMap->getModificationDateColumnName() !== NULL) {
			$row[$dataMap->getModificationDateColumnName()] = $GLOBALS['EXEC_TIME'];
		}
		if ($dataMap->getRecordTypeColumnName() !== NULL && 
$dataMap->getRecordType() !== NULL) {
			$row[$dataMap->getRecordTypeColumnName()] = $dataMap->getRecordType();
		}
         if ($object->_isNew() && !isset($row['pid'])) {
			$row['pid'] = $this->determineStoragePageIdForNewRecord($object);
		}
	}


And here is the method with my "fix":


	/**
	 * Returns a table row to be inserted or updated in the database
	 *
	 * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The 
appropriate data map representing a database table
	 * @param array $properties The properties of the object
	 * @return array A single row to be inserted in the database
	 */
	protected function 
addCommonFieldsToRow(Tx_Extbase_DomainObject_DomainObjectInterface 
$object, array &$row) {
		$className = get_class($object);
		$dataMap = $this->dataMapper->getDataMap($className);
		if ($object->_isNew() && ($dataMap->getCreationDateColumnName() !== 
NULL)) {
			$row[$dataMap->getCreationDateColumnName()] = $GLOBALS['EXEC_TIME'];
		}
		if ($dataMap->getModificationDateColumnName() !== NULL) {
			$row[$dataMap->getModificationDateColumnName()] = $GLOBALS['EXEC_TIME'];
		}
		if ($dataMap->getRecordTypeColumnName() !== NULL && 
$dataMap->getRecordType() !== NULL) {
			$row[$dataMap->getRecordTypeColumnName()] = $dataMap->getRecordType();
		}
		
		// FIX: Added by Michael Knoll 16.9.2009
		if (method_exists($object, 'getPid')) {
			$row['pid'] = $object->getPid();
		}
         if ($object->_isNew() && !isset($row['pid'])) {
			$row['pid'] = $this->determineStoragePageIdForNewRecord($object);
		}
	}


After testing this, the object will not have a "pid"-property set, after 
being reconstituted from a database record, although the record has PID 
set correctly...


Why can't I handle a "pid"-property like all other properties, if I want 
to do so?!?

*veryconfused*

Michael


More information about the TYPO3-project-typo3v4mvc mailing list