Skip to content

Commit

Permalink
Merge pull request #120 from digio-ch/issue/hc-246
Browse files Browse the repository at this point in the history
Encoding error in import logic
  • Loading branch information
SebastianStorz committed May 27, 2024
2 parents 310e553 + 5dd2323 commit 1c77d95
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Command/ImportFromJsonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ private function importRoleTypes(OutputInterface $output)
$role->setItLabel($roleType['label_it']);

$this->em->persist($role);
$this->em->flush();
if (0 === ($i % $this->batchSize)) {
$this->em->flush();
}
$i++;
}
$this->em->flush();
$timeElapsed = microtime(true) - $start;
$this->stats[] = ['role_types.json', $timeElapsed, $i];
$output->writeln([sprintf('%s rows imported from roles_types.json', $i)]);
Expand Down Expand Up @@ -534,7 +537,7 @@ private function importCamps(OutputInterface $output)
$metadata->setIdGenerator(new AssignedGenerator());
}
$camp->setState($c['state']);
$camp->setLocation(substr($c['location'], 0, 255));
$camp->setLocation(mb_convert_encoding(substr($c['location'], 0, 255),'UTF-8', 'US-ASCII'));

if (isset($c['name'])) {
$camp->setName($c['name']);
Expand Down Expand Up @@ -567,7 +570,7 @@ private function importCamps(OutputInterface $output)
}

$this->em->persist($camp);
if ($i % 10) {
if(0 == $i % 10) {
$this->em->flush();
}
$i++;
Expand Down

0 comments on commit 1c77d95

Please sign in to comment.