【发布时间】:2019-09-16 20:14:27
【问题描述】:
我想更新调度程序任务中的一些 Extbase 对象。我正在调用存储库来获取所有对象。然后我设置该对象的一个属性,并尝试更新它。 这抛出了我这个异常
提供给更新的“FFPI\FfpiNodeUpdates\Domain\Model\Node”类型的对象必须已经持久化,但是是新的。
vendor/typo3/cms/typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php:237
痕迹是:
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
...
我的代码可以缩短到这个
$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
}
它在 7.6 中运行良好,但在 8.7 中不再运行
我尝试使用
获取存储库
* 依赖注入(根本不起作用)
* GeneralUtility::makeInstance()(我得到了 repo,但有例外)
* objectManager->get() (我得到了 repo,但有例外)
更新: 我在 9.5 版也有这个问题
【问题讨论】:
标签: typo3 typo3-8.x typo3-9.x typo3-extensions