Fix for schema_version checksum table when checking schemas before the table's been added. :)
This commit is contained in:
		| @@ -95,11 +95,20 @@ class SchemaUpdater | |||||||
|     { |     { | ||||||
|         $checksums = array(); |         $checksums = array(); | ||||||
|  |  | ||||||
|         $sv = new Schema_version(); |         PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION); | ||||||
|         $sv->find(); |         try { | ||||||
|         while ($sv->fetch()) { |             $sv = new Schema_version(); | ||||||
|             $checksums[$sv->table_name] = $sv->checksum; |             $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; |         return $checksums; | ||||||
|     } |     } | ||||||
| @@ -112,15 +121,22 @@ class SchemaUpdater | |||||||
|      */ |      */ | ||||||
|     protected function saveChecksum($table, $checksum) |     protected function saveChecksum($table, $checksum) | ||||||
|     { |     { | ||||||
|         $sv = new Schema_version(); |         PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION); | ||||||
|         $sv->table_name = $table; |         try { | ||||||
|         $sv->checksum = $checksum; |             $sv = new Schema_version(); | ||||||
|         $sv->modified = common_sql_now(); |             $sv->table_name = $table; | ||||||
|         if (isset($this->checksums[$table])) { |             $sv->checksum = $checksum; | ||||||
|             $sv->update(); |             $sv->modified = common_sql_now(); | ||||||
|         } else { |             if (isset($this->checksums[$table])) { | ||||||
|             $sv->insert(); |                 $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; |         $this->checksums[$table] = $checksum; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user