| @@ -1,52 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Core\Fallback; |
| 4 | 4 | |
| 5 | -use BitCode\BitForm\Core\Database\DB; | |
| 6 | 5 | use BitCode\BitForm\Core\Database\WorkFlowModel; |
| 7 | 6 | use BitCode\BitForm\Core\Util\IpTool; |
| 8 | 7 | |
| 9 | 8 | class WorkFlow |
| 10 | 9 | { |
| 11 | - /** | |
| 12 | - * Free/Pro conditional-logic separation: backfill workflow_category on existing rows. | |
| 13 | - * | |
| 14 | - * The DB migration adds the column with DEFAULT 'classic', so every pre-existing row is already | |
| 15 | - * classic (= keeps executing in Free exactly as before). Here we only retag rows that the basic | |
| 16 | - * field show/hide UI marked as info.type === 'basic'. Existing rows predate the advanced (Pro) | |
| 17 | - * feature, so nothing legitimately maps to 'advanced' during this one-time upgrade. | |
| 18 | - */ | |
| 19 | - public function normalizeCategory() | |
| 20 | - { | |
| 21 | - // Self-heal `workflow_category` first, else this pass silently leaves rows uncategorized. | |
| 22 | - if (!DB::ensureWorkflowSchema()) { | |
| 23 | - return ''; | |
| 24 | - } | |
| 25 | - | |
| 26 | - $workFlowModel = new WorkFlowModel(); | |
| 27 | - $workFlows = $workFlowModel->get( | |
| 28 | - ['id', 'workflow_info', 'workflow_category'], | |
| 29 | - [], | |
| 30 | - null, | |
| 31 | - null, | |
| 32 | - 'id' | |
| 33 | - ); | |
| 34 | - if (is_wp_error($workFlows) || count($workFlows) <= 0) { | |
| 35 | - return ''; | |
| 36 | - } | |
| 37 | - foreach ($workFlows as $workflow) { | |
| 38 | - $info = !empty($workflow->workflow_info) ? \json_decode($workflow->workflow_info) : null; | |
| 39 | - $category = (!empty($info) && isset($info->type) && 'basic' === $info->type) ? 'basic' : 'classic'; | |
| 40 | - if ($category !== $workflow->workflow_category) { | |
| 41 | - $workFlowModel->update( | |
| 42 | - ['workflow_category' => $category], | |
| 43 | - ['id' => $workflow->id] | |
| 44 | - ); | |
| 45 | - } | |
| 46 | - } | |
| 47 | - } | |
| 48 | - | |
| 49 | 10 | public function conditionalLogic() |
| 50 | 11 | { |
| 51 | 12 | $workFlowUpdatedSatus = true; |
| 52 | 13 | $workFlowModel = new WorkFlowModel(); |
| @@ -55,9 +16,8 @@ | ||
| 55 | 16 | 'id', |
| 56 | 17 | 'workflow_behaviour', |
| 57 | 18 | 'workflow_condition', |
| 58 | 19 | 'workflow_action', |
| 59 | - 'workflow_status', | |
| 60 | 20 | ], |
| 61 | 21 | [], |
| 62 | 22 | null, |
| 63 | 23 | null, |
| @@ -102,9 +62,8 @@ | ||
| 102 | 62 | } |
| 103 | 63 | } |
| 104 | 64 | if ($workFlowUpdatedSatus) { |
| 105 | 65 | global $wpdb; |
| 106 | - // Schema migration: table name interpolation only. $wpdb->prepare() cannot parameterize DDL statements. | |
| 107 | 66 | $wpdb->query( |
| 108 | 67 | "ALTER TABLE `{$wpdb->prefix}bitforms_workflows` DROP `workflow_action`" |
| 109 | 68 | ); |
| 110 | 69 | } |