TYPO3 Exception 1249479819

Persistence

You need to make sure that your object is already persisted before calling Repository->update($o); Add it first with Repository->add($o);

Usage of (new) property mapper / t3extblog

I encountered this exception when trying to install/use t3extblog with TYPO3 6.2.10. Check your code for correct usage of (new) property mapper, this should give you a hint (taken from https://forge.typo3.org/issues/51330):

old property mapper is not supported anymore and removed from the Core after 6.2. Use the new one instead.

For those who do not know how to fix it, I will show how I have fixed it.

Old code:

$persistenceManager =
\\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Persistence_Manager');
Copied!

New code:

$objectManager =
\\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$persistenceManager =
$objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
Copied!

Object retrieved by property mapper can't get updated via persistence manager

If you try to ->update() an object which has been retrieved from the property mapper by mapping GET/POST parameters, so if you pass the object as argument of your controller action, this issue may occur.

For me the solution was to re-retrieve the object using the repository and ->findByUid() method and then persist/update the retrieved object. It seems the repository needs to "know" about the object.

function yourAction(\Some\Model $item)
{
    $updateItem = $this->itemRepository->findByUid($item->getUid());
    /**
     *  something with $updateItem ...
     */
    $this->itemRepository->update($updateItem);
}
Copied!