From 8cdf8cf33e8b98d8d49dc03777dd5c39fb28c4d6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 28 Feb 2011 11:19:47 -0800 Subject: [PATCH] Fix for schema_version checksum table when checking schemas before the table's been added. :) --- lib/schemaupdater.php | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/schemaupdater.php b/lib/schemaupdater.php index 64f7c596d4..1960a06930 100644 --- a/lib/schemaupdater.php +++ b/lib/schemaupdater.php @@ -95,11 +95,20 @@ class SchemaUpdater { $checksums = array(); - $sv = new Schema_version(); - $sv->find(); - while ($sv->fetch()) { - $checksums[$sv->table_name] = $sv->checksum; + PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION); + try { + $sv = new Schema_version(); + $sv->find(); + while ($sv->fetch()) { + $checksums[$sv->table_name] = $sv->checksum; + } + + return $checksums; + } catch (Exception $e) { + // no dice! + common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet."); } + PEAR::popErrorHandling(); return $checksums; } @@ -112,15 +121,22 @@ class SchemaUpdater */ protected function saveChecksum($table, $checksum) { - $sv = new Schema_version(); - $sv->table_name = $table; - $sv->checksum = $checksum; - $sv->modified = common_sql_now(); - if (isset($this->checksums[$table])) { - $sv->update(); - } else { - $sv->insert(); + PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION); + try { + $sv = new Schema_version(); + $sv->table_name = $table; + $sv->checksum = $checksum; + $sv->modified = common_sql_now(); + if (isset($this->checksums[$table])) { + $sv->update(); + } else { + $sv->insert(); + } + } catch (Exception $e) { + // no dice! + common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet."); } + PEAR::popErrorHandling(); $this->checksums[$table] = $checksum; } }