Skip to content

Commit

Permalink
GP-44069 Fix DB error when building container prior to upgrader
Browse files Browse the repository at this point in the history
  • Loading branch information
pfigel committed Oct 1, 2024
1 parent 3af5b3b commit 5cb0736
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Civi/Sqltasks/CompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ public function process(ContainerBuilder $container) {
E::ts('Run SQL Task'),
], []);

$query = \CRM_Core_DAO::executeQuery("
SELECT id FROM civicrm_sqltasks WHERE input_spec IS NOT NULL ORDER BY id ASC;
");
try {
$errorScope = \CRM_Core_TemporaryErrorScope::useException();
$query = \CRM_Core_DAO::executeQuery("
SELECT id FROM civicrm_sqltasks WHERE input_spec IS NOT NULL ORDER BY id ASC;
");
}
catch (\Civi\Core\Exception\DBQueryException $e) {
// if this is executed before the upgrader for input_spec runs, civi doesn't boot
if (str_contains($e->getMessage(), 'DB Error: no such field')) {
// would like to log this, but seems to cause infinite loop in the container build process
// \Civi::log()->warning('Unable to add action providers. Please run upgraders to create column civicrm_sqltasks.input_spec');
return;
}
throw $e;
}

while ($query->fetch()) {
$task_id = $query->id;
Expand Down

0 comments on commit 5cb0736

Please sign in to comment.