PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
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/Integration/Integrations.php +5 -113 3.2.22.15.3 View file →
@@ -9,9 +9,8 @@
9 9
10 10 use BitCode\BitForm\Core\Database\FormEntryModel;
11 11 use BitCode\BitForm\Core\Database\FormModel;
12 12 use BitCode\BitForm\Core\Util\ApiResponse;
13 -use BitCode\BitForm\Core\Util\Log;
14 13 use BitCode\BitForm\Core\Util\SmartTags;
15 14 use BitCode\BitForm\Core\Util\Utilities;
16 15 /**
17 16 * Provides details of available integration and helps to
@@ -22,23 +21,11 @@
22 21
23 22 final class Integrations
24 23 {
25 24 public $integrations = [];
26 - private static $_instance = null;
27 25
28 26 /**
29 27 * Undocumented function
30 - */
31 - public static function getInstance()
32 - {
33 - if (null === self::$_instance) {
34 - self::$_instance = new Integrations();
35 - }
36 - return self::$_instance;
37 - }
38 -
39 - /**
40 - * Undocumented function
41 28 *
42 29 * @return array
43 30 */
44 31 public function getAllIntegrations()
@@ -181,70 +168,37 @@
181 168 public static function executeIntegrations($integrations, $fieldValues, $formID, $logID = null, $entryID = 0)
182 169 {
183 170 $integrationHandler = new IntegrationHandler($formID);
184 171 $logResponse = new ApiResponse();
185 - $intThatNeedNoFileHandling = ['ACF', 'MetaBox', 'Pods']; //these takes raw file and upload it
186 - $baseFieldValues = $fieldValues;
187 - $entryDetails = [
188 - 'formId' => $formID,
189 - 'entryId' => $entryID,
190 - 'fieldValues' => $fieldValues
191 - ];
192 172 if (is_array($integrations)) {
193 173 foreach ($integrations as $integrationIDStr) {
194 174 if (!is_string($integrationIDStr)) {
195 175 return;
196 176 }
197 - $currentFieldValues = $baseFieldValues;
198 - $integrationID = intval(Utilities::jsonObj($integrationIDStr)->id ?? 0, 10);
177 + $integrationID = intval(json_decode($integrationIDStr)->id, 10);
199 178 if (!empty($integrationID) && is_int($integrationID)) {
200 179 $integrationResult
201 180 = $integrationHandler->getAIntegration($integrationID);
202 181 $integrationDetails = is_wp_error($integrationResult) ? null : $integrationResult[0];
203 - // Honor enable/disable: a disabled integration is never executed.
204 - if (!is_null($integrationDetails) && isset($integrationDetails->status) && empty($integrationDetails->status)) {
205 - continue;
206 - }
207 182 $integrationName = is_null($integrationDetails) ? null : ucfirst(str_replace(' ', '', $integrationDetails->integration_type));
208 183 if ('Brevo(SendinBlue)' === $integrationName) {
209 184 $integrationName = 'SendinBlue';
210 185 }
211 186 if (!is_null($integrationName) && static::isExists($integrationName)) {
212 - if (!in_array($integrationName, $intThatNeedNoFileHandling)) {
213 - $currentFieldValues = IntegrationHandler::handleFileUrl($currentFieldValues, $formID, $entryID);
214 - }
215 187 $integration = static::isExists($integrationName);
216 188 $handler = new $integration($integrationID, $formID);
217 189 $integDetails = is_string($integrationDetails->integration_details) ? json_decode($integrationDetails->integration_details) : $integrationDetails->integration_details;
218 190 if (isset($integDetails->field_map)) {
219 191 $sptagData = self::specialTagFields($integDetails->field_map);
220 - $currentFieldValues = $currentFieldValues + $sptagData;
192 + $fieldValues = $fieldValues + $sptagData;
221 193 }
222 - // fresh time budget per handler: a chain of slow integrations (30s HTTP
223 - // timeout each) must not be killed by max_execution_time mid-loop
224 - if (\function_exists('set_time_limit') && false === strpos((string) ini_get('disable_functions'), 'set_time_limit')) {
225 - set_time_limit(60);
226 - }
227 - try {
228 - $handler->execute($integrationHandler, $integrationDetails, $currentFieldValues, $entryID, $logID);
229 - } catch (\Throwable $executionError) {
230 - // one failing integration must not abort the remaining ones
231 - Log::debug_log('[+] Integration execution threw: ' . $executionError->getMessage());
232 - $logResponse->apiResponse(
233 - $logID,
234 - $integrationID,
235 - ['type' => 'record', 'type_name' => $integrationName ?: 'Integration'],
236 - 'errors',
237 - $executionError->getMessage(),
238 - $entryDetails
239 - );
240 - }
194 + $handler->execute($integrationHandler, $integrationDetails, $fieldValues, $entryID, $logID);
241 195 } else {
242 196 do_action('bitform_integration_run_failure', $integrationID, $formID);
243 197
244 198 $errorMsg = apply_filters('bitform_filter_integration_run_failure_message', __('Integration execution failed', 'bit-form'), $integrationID, $formID);
245 199
246 - Log::debug_log('[+] Integration execution failed: ' . $errorMsg);
200 + error_log('[+] Integration execution failed: ' . print_r($errorMsg, true));
247 201
248 202 $logResponse->apiResponse(
249 203 $logID,
250 204 $integrationID,
@@ -249,10 +203,9 @@
249 203 $logID,
250 204 $integrationID,
251 205 ['type' => 'record', 'type_name' => $integrationName || 'Integration'],
252 206 'errors',
253 - $errorMsg,
254 - $entryDetails
207 + $errorMsg
255 208 );
256 209 }
257 210 }
258 211 }
@@ -272,67 +225,6 @@
272 225 foreach ($integrations as $key => $value) {
273 226 self::executeIntegrations($value, $fieldValue, $formID, $logID, $entryID);
274 227 }
275 228 self::entryDeleted($formID, $entryID);
276 - }
277 -
278 - /**
279 - * This function helps to save connected integration app
280 - *
281 - * @return wp_error | mixed
282 - */
283 - public function saveConnectedIntegrationApp($appConfig)
284 - {
285 - // error_log('[+] saveConnectedIntegrationApp: ' . print_r($appConfig, true));
286 - $connectionName = $appConfig->name;
287 - $connectionType = $appConfig->type;
288 - // $connectionDetails = wp_json_encode($appConfig);
289 -
290 - if (empty($appConfig->details)) {
291 - unset($appConfig->name, $appConfig->id);
292 -
293 - $connectionDetails = !is_string($appConfig) ?
294 - wp_json_encode($appConfig) : $appConfig;
295 - } else {
296 - $connectionDetails = !is_string($appConfig->details) ?
297 - wp_json_encode($appConfig->details) : $appConfig->details;
298 - }
299 - $connectionCategory = 'connected_integration_apps';
300 -
301 - $integrationHandler = new IntegrationHandler(0);
302 -
303 - return $integrationHandler->saveIntegration($connectionName, $connectionType, $connectionDetails, $connectionCategory);
304 - }
305 -
306 - // get connectd integration app
307 - public function getConnectedIntegrationApp($integration_type = null)
308 - {
309 - $connectionCategory = 'connected_integration_apps';
310 -
311 - $integrationHandler = new IntegrationHandler(0);
312 - $allConnectedIntegApps = $integrationHandler->getAllIntegration($connectionCategory, $integration_type);
313 -
314 - if (!is_wp_error($allConnectedIntegApps)) {
315 - foreach ($allConnectedIntegApps as $integrationkey => $integrationValue) {
316 - $integrationData = [
317 - 'id' => $integrationValue->id,
318 - 'name' => $integrationValue->integration_name,
319 - 'type' => $integrationValue->integration_type,
320 - ];
321 - $allConnectedIntegApps[$integrationkey]->integration_details = wp_json_encode(array_merge(
322 - $integrationData,
323 - is_string($integrationValue->integration_details) ?
324 - (array) json_decode($integrationValue->integration_details) :
325 - $integrationValue->integration_details
326 - ));
327 - }
328 - }
329 - return $allConnectedIntegApps;
330 - }
331 -
332 - public function deleteConnectedApp($appId)
333 - {
334 - $integrationHandler = new IntegrationHandler(0);
335 -
336 - return $integrationHandler->deleteIntegration($appId);
337 229 }
338 230 }