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/FormEntryLogModel.php +71 -0 3.1.33.3.1 View file →
@@ -90,8 +90,79 @@
90 90 );
91 91 return $this->execute($sql)->getResult();
92 92 }
93 93
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 + /**
115 + * Newest still-queued workflow row of an entry, for callers that hold the
116 + * entry id but not the queue log id (the payment endpoints).
117 + *
118 + * @return object|null row with id and response_obj
119 + */
120 + public function latestQueuedWorkflowByEntry($entryID)
121 + {
122 + $sql = "SELECT ld.id, ld.response_obj
123 + FROM `{$this->app_db->prefix}bitforms_form_log_details` ld
124 + JOIN `{$this->app_db->prefix}bitforms_form_entry_log` el ON el.id = ld.log_id
125 + WHERE el.form_entry_id = %d
126 + AND ld.integration_id = 0
127 + AND ld.response_type = 'queued'
128 + ORDER BY ld.id DESC
129 + LIMIT 1";
130 + $rows = $this->execute($sql, [absint($entryID)])->getResult();
131 +
132 + return is_wp_error($rows) || empty($rows) ? null : $rows[0];
133 + }
134 +
135 + /**
136 + * Patch a queued row's payload. The 'queued' condition keeps it off rows a
137 + * trigger or the reclaim cron has already claimed.
138 + *
139 + * @return mixed rows affected, or WP_Error
140 + */
141 + public function updateQueuedWorkflowResponse($queueLogId, array $responseObj)
142 + {
143 + return $this->update(
144 + ['response_obj' => wp_json_encode($responseObj)],
145 + ['id' => absint($queueLogId), 'response_type' => 'queued']
146 + );
147 + }
148 +
149 + /**
150 + * Latest execution per integration of a form: last run time plus the
151 + * response_type of that newest log row. integration_id 0 (workflow queue) excluded.
152 + */
153 + public function getIntegrationLastRuns($formId)
154 + {
155 + $sql = "SELECT ld.integration_id,
156 + MAX(ld.created_at) AS lastRun,
157 + SUBSTRING_INDEX(GROUP_CONCAT(ld.response_type ORDER BY ld.created_at DESC, ld.id DESC), ',', 1) AS lastStatus
158 + FROM `{$this->app_db->prefix}bitforms_form_log_details` ld
159 + JOIN `{$this->app_db->prefix}bitforms_form_entry_log` el ON el.id = ld.log_id
160 + WHERE el.form_id = %d AND ld.integration_id > 0
161 + GROUP BY ld.integration_id";
162 + return $this->execute($sql, [absint($formId)])->getResult();
163 + }
164 +
94 165 public function logUpdate($updateValue, $logID)
95 166 {
96 167 if (empty($logID)) {
97 168 return false;