Skip to content

Commit 7e3263f

Browse files
committed
Don't remove characters from expression
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
1 parent dc95d18 commit 7e3263f

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

libraries/classes/Table/ColumnsDefinition.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
use function in_array;
2525
use function intval;
2626
use function is_array;
27+
use function mb_strlen;
2728
use function mb_strtoupper;
2829
use function preg_quote;
2930
use function preg_replace;
3031
use function rtrim;
32+
use function str_ends_with;
33+
use function str_starts_with;
3134
use function stripcslashes;
3235
use function substr;
3336
use function trim;
@@ -514,8 +517,6 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
514517
// Could be null or empty string here
515518
if ($columnMeta['Default'] === null) {
516519
$metaDefault['DefaultType'] = $columnMeta['Null'] === 'YES' ? 'NULL' : 'NONE';
517-
} else {
518-
$columnMeta['DefaultValue'] = $columnMeta['Default'];
519520
}
520521

521522
break;
@@ -531,8 +532,16 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
531532
break;
532533
default:
533534
if (substr((string) $columnMeta['Type'], -4) === 'text') {
534-
$textDefault = substr($columnMeta['Default'], 1, -1);
535-
$metaDefault['DefaultValue'] = stripcslashes($textDefault);
535+
if (
536+
mb_strlen($columnMeta['Default']) >= 2 &&
537+
str_starts_with($columnMeta['Default'], "'") &&
538+
str_ends_with($columnMeta['Default'], "'")
539+
) {
540+
$textDefault = substr($columnMeta['Default'], 1, -1);
541+
$metaDefault['DefaultValue'] = stripcslashes($textDefault);
542+
} else {
543+
$metaDefault['DefaultValue'] = $columnMeta['Default'];
544+
}
536545
} else {
537546
$metaDefault['DefaultValue'] = $columnMeta['Default'];
538547
}

0 commit comments

Comments
 (0)