From cd20b4b26cf291473171a3ba96fda5a6e006821f Mon Sep 17 00:00:00 2001 From: Waldo Jaquith Date: Mon, 25 Nov 2024 11:21:51 -0500 Subject: [PATCH] Stop trying to insert if the DB goes away --- cron/fiscal_impact.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cron/fiscal_impact.php b/cron/fiscal_impact.php index 90fbfc4..efbe765 100644 --- a/cron/fiscal_impact.php +++ b/cron/fiscal_impact.php @@ -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 @@ -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); } }