[TYPO3-mvc] Bug in Backend.php

Michael Knoll mimi at kaktusteam.de
Thu Sep 16 15:01:38 CEST 2010


Hi there,

I still have problems with storage pids. What I want to do is set a 
storage pid for a NEW record... so I added $pid as a property on my 
record and wrote getter and setter for it. Now I thought, that setting 
this pid would do the job... fail.

Here is the piece of code that handles storage pid in the Extbase 
Persistence Backend class:


	/**
	 * Determine the storage page ID for a given NEW record
	 *
	 * This does the following:
	 * - If there is a TypoScript configuration 
"classes.CLASSNAME.newRecordStoragePid", that is used to store new records.
	 * - If there is no such TypoScript configuration, it uses the first 
value of The "storagePid" taken for reading records.
	 *
	 * @param Tx_Extbase_DomainObject_DomainObjectInterface $object
	 * @return int the storage Page ID where the object should be stored
	 */
	protected function 
determineStoragePageIdForNewRecord(Tx_Extbase_DomainObject_DomainObjectInterface 
$object) {
		$className = get_class($object);
		$extbaseSettings = 
Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration();

		if (isset($extbaseSettings['persistence']['classes'][$className]) && 
!empty($extbaseSettings['persistence']['classes'][$className]['newRecordStoragePid'])) 
{
			return 
(int)$extbaseSettings['persistence']['classes'][$className]['newRecordStoragePid'];
		} else {
			$storagePidList = t3lib_div::intExplode(',', 
$extbaseSettings['persistence']['storagePid']);
			return (int) $storagePidList[0];
		}
	}


So I miss the case, when a PID is set on the object... that should do 
the job - am I wrong? Here is my FIX for this:


		if (method_exists($object, 'getPid')) {
			$row['pid'] = $object->getPid();
		}
         if ($object->_isNew() && !isset($row['pid'])) {
			$row['pid'] = $this->determineStoragePageIdForNewRecord($object);
		}



Could you please add those lines in ExtBase, that would make using 
persistence stuff a lot easier.


Greez

Mimi



More information about the TYPO3-project-typo3v4mvc mailing list