| @@ -30,9 +30,9 @@ | ||
| 30 | 30 | |
| 31 | 31 | if (isset($integrations->errors['result_empty'])) { |
| 32 | 32 | $integrations = []; |
| 33 | 33 | } else { |
| 34 | - foreach ($logs as $key => $log) { | |
| 34 | + foreach ($logs as $key => $log) { | |
| 35 | 35 | foreach ($integrations as $integration) { |
| 36 | 36 | if ($integration->log_id === $log->id) { |
| 37 | 37 | $logs[$key]->integration = true; |
| 38 | 38 | } |
| @@ -48,13 +48,9 @@ | ||
| 48 | 48 | { |
| 49 | 49 | if (is_null($entry_id)) { |
| 50 | 50 | return new WP_Error('empty_data', __('Form data is empty', 'bit-form')); |
| 51 | 51 | } |
| 52 | - $sql = $this->app_db->prepare( | |
| 53 | - "SELECT api_type, response_obj FROM `{$this->app_db->prefix}bitforms_form_entry_log` as el JOIN `{$this->app_db->prefix}bitforms_form_log_details` as ld ON ld.log_id = el.id WHERE form_entry_id = %d AND integration_id = %d AND ld.response_type = 'success' ORDER BY el.id DESC LIMIT 1", | |
| 54 | - $entry_id, | |
| 55 | - $integ_id | |
| 56 | - ); | |
| 52 | + $sql = "SELECT api_type, response_obj FROM `{$this->app_db->prefix}bitforms_form_entry_log` as el JOIN `{$this->app_db->prefix}bitforms_form_log_details` as ld ON ld.log_id = el.id WHERE form_entry_id = {$entry_id} AND integration_id = {$integ_id} AND ld.response_type = 'success' ORDER BY el.id DESC LIMIT 1"; | |
| 57 | 53 | |
| 58 | 54 | return $this->app_db->get_results($sql); |
| 59 | 55 | } |
| 60 | 56 | |
| @@ -83,44 +79,17 @@ | ||
| 83 | 79 | } |
| 84 | 80 | |
| 85 | 81 | public function get_form_value($form_id = '') |
| 86 | 82 | { |
| 87 | - $sql = $this->app_db->prepare( | |
| 88 | - "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` WHERE bitforms_form_entry_id=%d", | |
| 89 | - $form_id | |
| 90 | - ); | |
| 83 | + $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$form_id"; | |
| 91 | 84 | return $this->execute($sql)->getResult(); |
| 92 | 85 | } |
| 93 | 86 | |
| 94 | - /** | |
| 95 | - * Queued workflow-trigger rows (response_type 'queued', integration_id 0) | |
| 96 | - * whose browser trigger and per-entry reclaim event were both lost, joined | |
| 97 | - * to the entry log for the form/entry ids the executor needs. | |
| 98 | - */ | |
| 99 | - public function getStaleQueuedWorkflows($minAgeMinutes, $maxAgeHours, $limit) | |
| 100 | - { | |
| 101 | - $sql = "SELECT ld.id AS queue_log_id, ld.log_id, el.form_id, el.form_entry_id | |
| 102 | - FROM `{$this->app_db->prefix}bitforms_form_log_details` ld | |
| 103 | - JOIN `{$this->app_db->prefix}bitforms_form_entry_log` el ON el.id = ld.log_id | |
| 104 | - WHERE ld.integration_id = 0 | |
| 105 | - AND ld.response_type = 'queued' | |
| 106 | - AND ld.created_at < DATE_SUB(%s, INTERVAL %d MINUTE) | |
| 107 | - AND ld.created_at > DATE_SUB(%s, INTERVAL %d HOUR) | |
| 108 | - ORDER BY ld.id ASC | |
| 109 | - LIMIT %d"; | |
| 110 | - $now = current_time('mysql'); | |
| 111 | - return $this->execute($sql, [$now, absint($minAgeMinutes), $now, absint($maxAgeHours), absint($limit)])->getResult(); | |
| 112 | - } | |
| 113 | - | |
| 114 | 87 | public function logUpdate($updateValue, $logID) |
| 115 | 88 | { |
| 116 | 89 | if (empty($logID)) { |
| 117 | 90 | return false; |
| 118 | 91 | } |
| 119 | - $sql = $this->app_db->prepare( | |
| 120 | - "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content=%s WHERE id=%d", | |
| 121 | - $updateValue, | |
| 122 | - $logID | |
| 123 | - ); | |
| 92 | + $sql = "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID"; | |
| 124 | 93 | return $this->execute($sql)->getResult(); |
| 125 | 94 | } |
| 126 | 95 | } |