Skip to content

Commit c6c6426

Browse files
committed
Txp 4.6.2 and MySQL 5.7 compatibility
* TEXT columns can't have default values * AUTOINCREMENT columns need omitting instead of sending empty '' strings
1 parent 3be3bb8 commit c6c6426

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

glz_custom_fields.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// run this file at the command line to produce a plugin for distribution:
55
// $ php abc_myplugin.php > abc_myplugin-0.1.txt
66

7-
$version = isset($_ENV["PLUGIN_VERSION"]) ? $_ENV["PLUGIN_VERSION"] : "1.4.0";
7+
$version = isset($_ENV["PLUGIN_VERSION"]) ? $_ENV["PLUGIN_VERSION"] : "1.5.0";
88

99
$plugin['code_file'] = realpath('glz_custom_fields_code.php');
1010
$plugin['help_file'] = realpath('glz_custom_fields_help.html');
@@ -13,7 +13,7 @@
1313
$plugin['author'] = "Gerhard Lazu";
1414
$plugin['author_uri'] = "http://gerhardlazu.com";
1515
$plugin['contributors'] = "Randy Levine, Sam Weiss, Luca Botti, Manfre, Vladimir Siljkovic, Julian Reisenberger, Steve Dickinson, Stef Dawson, Jean-Pol Dupont";
16-
$plugin['compatibility'] = "4.5.1";
16+
$plugin['compatibility'] = "4.6.2";
1717

1818
// Plugin load order:
1919
// The default value of 5 would fit most plugins, while for instance comment spam evaluators or URL redirectors

lib/db.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,19 @@ function glz_new_custom_field($name, $table, $extra) {
258258
else if ( $table == PFX."txp_lang" ) {
259259
$query = "
260260
INSERT INTO
261-
`".PFX."txp_lang` (`id`,`lang`,`name`,`event`,`data`,`lastmod`)
261+
`".PFX."txp_lang` (`lang`,`name`,`event`,`data`,`lastmod`)
262262
VALUES
263-
('','{$lang}','{$custom_set}','prefs','{$name}',now())
263+
('{$lang}','{$custom_set}','prefs','{$name}',now())
264264
";
265265
}
266266
else if ( $table == PFX."textpattern" ) {
267267
$column_type = ( $custom_set_type == "textarea" ) ? "TEXT" : "VARCHAR(255)";
268+
$dflt = ( $custom_set_type == "textarea" ) ? '' : "DEFAULT ''";
268269
$query = "
269270
ALTER TABLE
270271
`".PFX."textpattern`
271272
ADD
272-
`custom_{$custom_field_number}` {$column_type} NOT NULL DEFAULT ''
273+
`custom_{$custom_field_number}` {$column_type} NOT NULL {$dflt}
273274
";
274275
}
275276
else if ( $table == PFX."custom_fields" ) {
@@ -322,11 +323,12 @@ function glz_update_custom_field($name, $table, $extra) {
322323
}
323324
else if ( ($table == PFX."textpattern") ) {
324325
$column_type = ( $custom_set_type == "textarea" ) ? "TEXT" : "VARCHAR(255)";
326+
$dflt = ( $custom_set_type == "textarea" ) ? '' : "DEFAULT ''";
325327
safe_query("
326328
ALTER TABLE
327329
`".PFX."textpattern`
328330
MODIFY
329-
`{$custom_field}` {$column_type} NOT NULL DEFAULT ''
331+
`{$custom_field}` {$column_type} NOT NULL {$dflt}
330332
");
331333
}
332334
}

0 commit comments

Comments
 (0)