Skip to content

Commit

Permalink
Stop trying to insert if the DB goes away
Browse files Browse the repository at this point in the history
  • Loading branch information
waldoj committed Nov 25, 2024
1 parent 24343e7 commit cd20b4b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cron/fiscal_impact.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
}

// Insert the records
foreach ($fis as $bill_number => $fis_id)
{
foreach ($fis as $bill_number => $fis_id) {
$sql = 'UPDATE bills
SET impact_statement_id = "' . $fis_id . '"
WHERE number = "' . $bill_number . '" AND
Expand All @@ -48,8 +47,11 @@
if ($result === false) {
$log->put('Error: Adding a fiscal impact statement ID for ' . $bill_number . ' failed: '
. mysqli_error($GLOBALS['db']), 4);
}
else {
if (mysqli_error($GLOBALS['db']) == 'MySQL server has gone away') {
$log->put('Abandoning insertion of fiscal impact statement IDs.', 5);
break;
}
} else {
$log->put('Added a fiscal impact statement ID for ' . $bill_number . '.', 1);
}
}

0 comments on commit cd20b4b

Please sign in to comment.