I want to update some Extbase Objects in a Scheduler Task. I'm calling the Repository to get all Objects. Then I set one Property of that object, and Try do Update it. That throws me this Exception
The object of type "FFPI\FfpiNodeUpdates\Domain\Model\Node" given to update must be persisted already, but is new.
vendor/typo3/cms/typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php:237
the trace is:
0: TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
1: TYPO3\CMS\Extbase\Persistence\Repository
2: FFPI\FfpiNodeUpdates\Task\NotificationTask
3: FFPI\FfpiNodeUpdates\Task\NotificationTask
4: TYPO3\CMS\Scheduler\Scheduler
5: TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
...
my code can be shortened to this
$nodes = $this->nodeRepository->findAll()->toArray();
foreach ($nodes as $node){
$this->myUpdateFunction($node);
}
private function myUpdateFunction(Node $node)
{
$node->setOnline(true);
$this->nodeRepository->update($node); // <- Gives the exception
}
It worked fine in 7.6 but dose not work anymore in 8.7
I tried to get the Repository with
* dependency Injection (dose not work at all)
* GeneralUtility::makeInstance() (I get the repo, but have the exception)
* objectManager->get() (I get the repo, but have the exception)
Update: I have this problem also in version 9.5