From c5d1a53281cd254a1e1fbd85894076e1c1a96c99 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 10 Mar 2009 02:02:14 +0000 Subject: [PATCH] MINOR Fixed Database class PHP notices caused by a missing array index when running dev/build to create a new table git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@72750 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Database.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/model/Database.php b/core/model/Database.php index e58277fc5..f765a32b0 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -292,17 +292,20 @@ abstract class Database extends Object { if(!isset($this->tableList[strtolower($table)])) $newTable = true; - if(!$newTable && !isset($this->indexList[$table])) { + if(!$newTable && !isset($this->indexList[$table])) { $this->indexList[$table] = $this->indexList($table); } //Fix up the index for database purposes $index=DB::getConn()->getDbSqlDefinition($table, $index, null, true); - if(is_array($this->indexList[$table][$index])) - $array_spec=$this->indexList[$table][$index]['spec']; - else - $array_spec=$this->indexList[$table][$index]; + if(!$newTable) { + if(is_array($this->indexList[$table][$index])) { + $array_spec = $this->indexList[$table][$index]['spec']; + } else { + $array_spec = $this->indexList[$table][$index]; + } + } if($newTable || !isset($this->indexList[$table][$index])) { $this->transCreateIndex($table, $index, $spec); @@ -361,10 +364,14 @@ abstract class Database extends Object { // We need to get db-specific versions of the ID column: if($spec_orig==DB::getConn()->IdColumn()) $specValue=DB::getConn()->IdColumn(true); - - if(is_array($this->fieldList[$table][$field])) - $fieldValue=$this->fieldList[$table][$field]['data_type']; - else $fieldValue=$this->fieldList[$table][$field]; + + if(!$newTable) { + if(is_array($this->fieldList[$table][$field])) { + $fieldValue = $this->fieldList[$table][$field]['data_type']; + } else { + $fieldValue = $this->fieldList[$table][$field]; + } + } // Get the version of the field as we would create it. This is used for comparison purposes to see if the // existing field is different to what we now want