From 5886d4578bb4f0d8d0e84ff8a9284be07f4bac5d Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 21 May 2009 23:17:25 +0000 Subject: [PATCH] BUGFIX Fixed undefined variables in MySQLDatabase::indexList() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77581 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/MySQLDatabase.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php index 6c64056ba..08cd4060c 100644 --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -456,6 +456,8 @@ class MySQLDatabase extends Database { */ public function indexList($table) { $indexes = DB::query("SHOW INDEXES IN \"$table\""); + $groupedIndexes = array(); + $indexList = array(); foreach($indexes as $index) { $groupedIndexes[$index['Key_name']]['fields'][$index['Seq_in_index']] = $index['Column_name']; @@ -472,10 +474,12 @@ class MySQLDatabase extends Database { $groupedIndexes[$index['Key_name']]['type'] = ''; } } - - foreach($groupedIndexes as $index => $details) { - ksort($details['fields']); - $indexList[$index] = $details['type'] . '(' . implode(',',$details['fields']) . ')'; + + if($groupedIndexes) { + foreach($groupedIndexes as $index => $details) { + ksort($details['fields']); + $indexList[$index] = $details['type'] . '(' . implode(',',$details['fields']) . ')'; + } } return $indexList;