$this->db()->beginTransaction();
if (empty($someUser->Heroes))
{
$allHeroes = [];
foreach ($data['heroes'] AS $userId => $hero)
{
if (is_array($hero))
{
if (!isset($allHeroes[key($hero)]))
{
$allHeroes[key($hero)] = [];
}
foreach ($hero AS $heroName => $heroValue)
{
$allHeroes[key($hero)][] = $heroValue;
}
// below line will throw exception Array to string conversion but won't get logged in ACP
$allHeroes[key($hero)] = array_unique($allHeroes[key($hero)]);
}
else
{
$allHeroes[] = $hero;
}
}
$this->logHero($someUser, [$someOtherVariable], $allHeroes,);
}
$this->db()->commit();