Lukas W.
Well-known member
I'm getting a weird error on one of my cron jobs, when the job is run automatically through the job system. It runs fine however, when I manually start it. Any idea what that thing is trying to tell me? Or more important, how to fix it?
Code:
LogicException: Entity is read only src\XF\Mvc\Entity\Entity.php:517
Generated by: Unknown account Mar 19, 2018 at 12:15 PM
Stack trace
#0 src\XF\Mvc\Entity\Entity.php(505): XF\Mvc\Entity\Entity->set('rpgs_character_...', 1)
#1 src\addons\RPGS\Entity\Character.php(353): XF\Mvc\Entity\Entity->__set('rpgs_character_...', 1)
#2 src\XF\Mvc\Entity\Entity.php(1145): RPGS\Entity\Character->_postSave()
#3 src\addons\RPGS\Repository\RPG\Import.php(84): XF\Mvc\Entity\Entity->save()
#4 src\addons\RPGS\Repository\RPG\Import.php(43): RPGS\Repository\RPG\Import->importRPGLandRPG(Array, Object(League\Flysystem\EventableFilesystem\EventableFilesystem), Object(RPGS\Entity\Import))
#5 src\addons\RPGS\Cron\Import.php(16): RPGS\Repository\RPG\Import->processQueue()
#6 [internal function]: RPGS\Cron\Import::processQueue(Object(XF\Entity\CronEntry))
#7 src\XF\Job\Cron.php(36): call_user_func(Array, Object(XF\Entity\CronEntry))
#8 src\XF\Job\Manager.php(241): XF\Job\Cron->run(7.9999969005585)
#9 src\XF\Job\Manager.php(187): XF\Job\Manager->runJobInternal(Array, 7.9999969005585)
#10 src\XF\Job\Manager.php(76): XF\Job\Manager->runJobEntry(Array, 7.9999969005585)
#11 job.php(15): XF\Job\Manager->runQueue(false, 8)
#12 {main}
Request state
array(4) {
["url"] => string(8) "/job.php"
["referrer"] => string(30) "http://localhost:1337/rpgs/all"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
PHP:
foreach($characters as $character) {
/** @var \RPGS\Entity\Character $characterEntity */
$characterEntity = $this->em->create('RPGS:Character');
$characterEntity->rpg_id = $rpg->rpg_id;
$characterEntity->name = trim($character);
$characterEntity->user_id = $rpg->user_id;
$characterEntity->save();
}