PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Database/DB.php +128 -8 V3.0.23.3.1 View file →
@@ -20,8 +20,122 @@
20 20 * Undocumented function
21 21 *
22 22 * @return void
23 23 */
24 +
25 + /**
26 + * Idempotently add the email-template status/config columns.
27 + *
28 + * @return void
29 + */
30 + public static function ensureEmailTemplateStatusColumn()
31 + {
32 + global $wpdb;
33 + $emailTable = $wpdb->prefix . 'bitforms_email_template';
34 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$emailTable}` LIKE 'status'")) {
35 + // Schema migration: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize DDL.
36 + $wpdb->query(
37 + "ALTER TABLE `{$emailTable}`
38 + ADD COLUMN `status` TINYINT(1) DEFAULT 1 AFTER `body`,
39 + ADD COLUMN `config` LONGTEXT NULL AFTER `status`"
40 + );
41 + }
42 + }
43 +
44 + /**
45 + * Idempotently add the workflows `workflow_info` column.
46 + *
47 + * @return void
48 + */
49 + public static function ensureWorkflowInfoColumn()
50 + {
51 + global $wpdb;
52 + $table = $wpdb->prefix . 'bitforms_workflows';
53 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table}` LIKE 'workflow_info'")) {
54 + // Schema migration: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize DDL.
55 + $wpdb->query(
56 + "ALTER TABLE `{$table}`
57 + ADD COLUMN `workflow_info` LONGTEXT NULL AFTER `workflow_condition`"
58 + );
59 + }
60 + }
61 +
62 + /**
63 + * Idempotently add the workflows `workflow_category` column (conditional-logic classic/basic split).
64 + *
65 + * @return void
66 + */
67 + public static function ensureWorkflowCategoryColumn()
68 + {
69 + self::ensureWorkflowInfoColumn();
70 + global $wpdb;
71 + $table = $wpdb->prefix . 'bitforms_workflows';
72 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table}` LIKE 'workflow_category'")) {
73 + // Schema migration: table name interpolation only (no user input). $wpdb->prepare() cannot parameterize DDL.
74 + $wpdb->query(
75 + "ALTER TABLE `{$table}`
76 + ADD COLUMN `workflow_category` VARCHAR(20) DEFAULT 'classic' AFTER `workflow_info`,
77 + ADD KEY `workflow_category` (`workflow_category`)"
78 + );
79 + }
80 + }
81 +
82 + /**
83 + * Idempotently add the workflows `workflow_order` column.
84 + *
85 + * @return void
86 + */
87 + public static function ensureWorkflowOrderColumn()
88 + {
89 + global $wpdb;
90 + $table = $wpdb->prefix . 'bitforms_workflows';
91 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table}` LIKE 'workflow_order'")) {
92 + $wpdb->query(
93 + "ALTER TABLE `{$table}`
94 + ADD COLUMN `workflow_order` INT(11) DEFAULT NULL AFTER `workflow_condition`"
95 + );
96 + }
97 + }
98 +
99 + /**
100 + * Idempotently add the workflows `workflow_status` column.
101 + *
102 + * @return void
103 + */
104 + public static function ensureWorkflowStatusColumn()
105 + {
106 + self::ensureWorkflowOrderColumn();
107 + global $wpdb;
108 + $table = $wpdb->prefix . 'bitforms_workflows';
109 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table}` LIKE 'workflow_status'")) {
110 + $wpdb->query(
111 + "ALTER TABLE `{$table}`
112 + ADD COLUMN `workflow_status` TINYINT(1) DEFAULT 1 NOT NULL AFTER `workflow_order`"
113 + );
114 + }
115 + }
116 +
117 + /**
118 + * Idempotently add every workflows column the queries reference, for installs whose
119 + * `bitforms_db_version` ran ahead of their real schema (a version-gated ALTER failed once).
120 + *
121 + * @return bool true when all four columns exist afterwards
122 + */
123 + public static function ensureWorkflowSchema()
124 + {
125 + global $wpdb;
126 + self::ensureWorkflowStatusColumn();
127 + self::ensureWorkflowCategoryColumn();
128 +
129 + $table = $wpdb->prefix . 'bitforms_workflows';
130 + foreach (['workflow_order', 'workflow_info', 'workflow_category', 'workflow_status'] as $column) {
131 + if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table}` LIKE '{$column}'")) {
132 + return false;
133 + }
134 + }
135 + return true;
136 + }
137 +
24 138 public static function migrate()
25 139 {
26 140 global $wpdb;
27 141 global $bitforms_db_version;
@@ -80,8 +194,9 @@
80 194 `workflow_run` varchar(50) NOT NULL,
81 195 `workflow_behaviour` varchar(25) NOT NULL,
82 196 `workflow_condition` longtext DEFAULT NULL,
83 197 `workflow_info` longtext DEFAULT NULL,
198 + `workflow_category` varchar(20) DEFAULT 'classic',/* classic = legacy, basic = field show/hide, advanced = multi-condition routing */
84 199 `workflow_order` int(11) unsigned DEFAULT NULL,
85 200 `workflow_status` tinyint(1) DEFAULT 1,/* 0 disable, 1 enable, 2 enable in field settings */
86 201 `form_id` bigint(20) unsigned DEFAULT NULL,
87 202 `user_id` bigint(20) unsigned DEFAULT NULL,
@@ -90,9 +205,10 @@
90 205 `user_device` varchar(50) DEFAULT NULL,
91 206 `created_at` datetime DEFAULT NULL,
92 207 `updated_at` datetime DEFAULT NULL,
93 208 PRIMARY KEY (`id`),
94 - KEY `form_id` (`form_id`)
209 + KEY `form_id` (`form_id`),
210 + KEY `workflow_category` (`workflow_category`)
95 211 ) $collate;",
96 212
97 213 "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}bitforms_success_messages` (
98 214 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@@ -111,8 +227,10 @@
111 227 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
112 228 `title` text DEFAULT NULL,
113 229 `sub` text DEFAULT NULL,
114 230 `body` longtext DEFAULT NULL,
231 + `status` tinyint(1) DEFAULT 1,/* 0 disabled, 1 enabled */
232 + `config` longtext DEFAULT NULL,/* SendTo / From / From Name / CC / BCC / Reply-To / attachments JSON */
115 233 `form_id` bigint(20) unsigned DEFAULT NULL,
116 234 `user_id` bigint(20) unsigned DEFAULT NULL,
117 235 `user_ip` int(11) unsigned DEFAULT NULL,
118 236 `created_at` datetime DEFAULT NULL,
@@ -279,15 +397,17 @@
279 397 }
280 398
281 399 // add workflow_info column if not exists
282 400 if ($installed_db_version && version_compare('3.0', $installed_db_version, '>=')) {
283 - $table_name = $wpdb->prefix . 'bitforms_workflows';
284 - if (null === $wpdb->get_var("SHOW COLUMNS FROM `{$table_name}` LIKE 'workflow_info'")) {
285 - $wpdb->query(
286 - "ALTER TABLE `{$table_name}`
287 - ADD COLUMN `workflow_info` LONGTEXT NULL AFTER `workflow_condition`"
288 - );
289 - }
401 + self::ensureWorkflowInfoColumn();
402 + }
403 +
404 + // add workflow_category column if not exists (conditional logic separation)
405 + // existing rows default to 'classic' so Free keeps executing them unchanged; data normalization in Fallback WorkFlow@normalizeCategory
406 + if ($installed_db_version && version_compare('3.2', $installed_db_version, '>=')) {
407 + self::ensureWorkflowCategoryColumn();
408 + // email template enable/disable + per-template config (SendTo/From/CC/BCC/Reply-To/attachments)
409 + self::ensureEmailTemplateStatusColumn();
290 410 }
291 411
292 412 update_option('bitforms_db_version', $bitforms_db_version, true);
293 413 } catch (\Exception $e) {