BUG Fix incorrect enum string parsing

This commit is contained in:
Damian Mooyman 2016-06-17 16:27:45 +12:00
parent b7ac5c564d
commit 009f2de17c
2 changed files with 6 additions and 7 deletions

View File

@ -647,11 +647,11 @@ abstract class DBSchemaManager {
// Update any records where the enum is set to a legacy value to be set to the default.
foreach (array('enum', 'set') as $enumtype) {
if (preg_match("/^$enumtype/i", $specValue)) {
$newStr = preg_replace("/(^$enumtype\s*\(')|('$\).*)/i", "", $spec_orig);
$new = preg_split("/'\s*,\s*'/", $newStr);
$newStr = preg_replace("/(^$enumtype\\s*\\(')|('\\).*)/i", "", $spec_orig);
$new = preg_split("/'\\s*,\\s*'/", $newStr);
$oldStr = preg_replace("/(^$enumtype\s*\(')|('$\).*)/i", "", $fieldValue);
$old = preg_split("/'\s*,\s*'/", $oldStr);
$oldStr = preg_replace("/(^$enumtype\\s*\\(')|('\\).*)/i", "", $fieldValue);
$old = preg_split("/'\\s*,\\s*'/", $oldStr);
$holder = array();
foreach ($old as $check) {

View File

@ -239,10 +239,9 @@ class MySQLSchemaManager extends DBSchemaManager {
public function fieldList($table) {
$fields = $this->query("SHOW FULL FIELDS IN \"$table\"");
$fieldList = array();
foreach ($fields as $field) {
// ensure that '' is converted to \' in field specification (mostly for the benefit of ENUM values)
$fieldSpec = str_replace('\'\'', '\\\'', $field['Type']);
$fieldSpec = $field['Type'];
if (!$field['Null'] || $field['Null'] == 'NO') {
$fieldSpec .= ' not null';
}