From 3a13be7703b86debaa393afbe53e7df18177bc23 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 1 Dec 2008 05:03:34 +0000 Subject: [PATCH] BUGFIX: Fixed db/build comparison for enum values git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@67076 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Database.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/model/Database.php b/core/model/Database.php index 17c1e610e..d76623636 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -334,14 +334,12 @@ abstract class Database extends Object { // Update any records where the enum is set to a legacy value to be set to the default. // One hard-coded exception is SiteTree - the default for this is Page. if(substr($spec, 0, 4) == "enum") { - $new = substr($spec, 5); - $old = substr($this->fieldList[$table][$field], 5); - $new = substr($new, 0, strpos($new, ')')); - $old = substr($old, 0, strpos($old, ')')); - $new = str_replace("'", '', $new); - $old = str_replace("'", '', $old); - $new = explode(',', $new); - $old = explode(',', $old); + $newStr = preg_replace("/(^enum\s*\(')|('$\).*)/i","",$spec); + $new = preg_split("/'\s*,\s*'/", $newStr); + + $oldStr = preg_replace("/(^enum\s*\(')|('$\).*)/i","",$this->fieldList[$table][$field]); + $old = preg_split("/'\s*,\s*'/", $newStr); + $holder = array(); foreach($old as $check) { if(!in_array($check, $new)) {