From 35e434386b11c47f4c97d5b23f302a6cd27b542b Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 7 Sep 2012 08:29:53 -0400 Subject: [PATCH] Fixed bug -- missing column detection did not work. --- .../VuFind/Controller/Plugin/DbUpgrade.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php b/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php index cc3b11a6dee..3d24e46aa7c 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php @@ -291,6 +291,27 @@ class DbUpgrade extends AbstractPlugin return $type == $expectedType; } + /** + * Support method for getModifiedColumns() -- check if the current column is + * in the missing column list so we can avoid modifying something that does + * not exist. + * + * @param string $column Column to check + * @param string $missing Missing column list for column's table. + * + * @return bool + */ + public function columnIsMissing($column, $missing) + { + foreach ($missing as $current) { + preg_match('/^\s*`([^`]*)`.*$/', $current, $matches); + if ($column == $matches[1]) { + return true; + } + } + return false; + } + /** * Get a list of changed columns in the database tables (associative array, * key = table name, value = array of column name => new data type). @@ -335,7 +356,9 @@ class DbUpgrade extends AbstractPlugin $actualColumns = $this->getTableColumns($table); foreach ($expectedColumns as $i => $column) { // Skip column if we're logging and it's missing - if (in_array($column, $missingColumns)) { + if (isset($missingColumns[$table]) + && $this->columnIsMissing($column, $missingColumns[$table]) + ) { continue; } $currentColumn = $actualColumns[$column]; -- GitLab