Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Installer] Deactivate foreign key checks while loading data into the…
… DB - follow up to #10486
  • Loading branch information
brusch committed Oct 20, 2021
1 parent 065e6da commit 338fcc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bundles/InstallBundle/Installer.php
Expand Up @@ -579,6 +579,9 @@ private function clearKernelCacheDir(KernelInterface $kernel)

public function setupDatabase(array $userCredentials, array $errors = []): array
{
$db = \Pimcore\Db::get();
$db->query('SET FOREIGN_KEY_CHECKS=0;');

if ($this->createDatabaseStructure) {
$mysqlInstallScript = file_get_contents(__DIR__ . '/Resources/install.sql');

Expand All @@ -588,7 +591,6 @@ public function setupDatabase(array $userCredentials, array $errors = []): array
// get every command as single part
$mysqlInstallScripts = explode(';', $mysqlInstallScript);

$db = \Pimcore\Db::get();
// execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..." seems to be a PDO bug after some googling
foreach ($mysqlInstallScripts as $m) {
$sql = trim($m);
Expand Down Expand Up @@ -627,6 +629,8 @@ public function setupDatabase(array $userCredentials, array $errors = []): array
}
}

$db->query('SET FOREIGN_KEY_CHECKS=1;');

return $errors;
}

Expand Down

0 comments on commit 338fcc9

Please sign in to comment.