Skip to content

Commit 212138b

Browse files
committed
default fields to not null
1 parent 8b3afa3 commit 212138b

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

_lib/api/v2/config.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,17 @@
44

55
function str_to_bool($str): string
66
{
7-
if ($str) {
8-
return 'true';
9-
}
10-
return 'false';
7+
return $str ? 'true' : 'false';
118
}
129

1310
function get_db_field($table, $field_name) {
14-
$old_field = [];
15-
1611
$cols = sql_query("SHOW FULL COLUMNS FROM `" . escape($table) . "`");
1712

1813
foreach ($cols as $field) {
19-
if ($field['Field'] == underscored($field_name)) {
20-
$db_field = $field['Type'];
21-
$null = $field['Null'] === 'NO' ? 'NOT NULL' : '';
22-
$old_field = $field;
23-
break;
14+
if ($field['Field'] === underscored($field_name)) {
15+
return $field;
2416
}
2517
}
26-
27-
return $old_field;
2818
}
2919

3020
global $last_modified,
@@ -214,7 +204,7 @@ function get_db_field($table, $field_name) {
214204
}
215205

216206
$db_field = $old_field['Type'] ?: $cms->form_to_db($_POST['type']);
217-
$null = $old_field['Null'] === 'NO' ? 'NOT NULL' : '';
207+
$null = $old_field['Null'] === 'YES' ? '' : 'NOT NULL';
218208
$extra = ($old_field['Extra'] === 'auto_increment' || $column === 'id') ? 'AUTO_INCREMENT' : '';
219209

220210
$default = $default ?: $old_field['Default'];

_lib/cms/cms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class cms
44
{
5-
const VERSION = '4.0.14';
5+
const VERSION = '4.0.15';
66

77
/**
88
* @var string

0 commit comments

Comments
 (0)