Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/cleantalk-admin-settings-page.min.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion css/src/cleantalk-admin-settings-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ button[value="save_changes"]:disabled {
color: red;
}

#apbct_negative_reports_table {
#apbct_negative_reports_table,
#apbct_negative_reports_table_api {
width: 100%;
border-collapse: collapse;
margin: 10px 5px;
Expand Down
40 changes: 39 additions & 1 deletion lib/Cleantalk/ApbctWP/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Cleantalk\ApbctWP;

use Cleantalk\ApbctWP\HTTP\Request;
use Cleantalk\Common\HTTP\Response;

/**
* Class API.
Expand Down Expand Up @@ -111,6 +112,43 @@ public static function sendRequest($data, $timeout = 10)
);
}

return $request->request();
$result = $request->request();

$http_code = $request->response instanceof Response
? $request->response->getResponseCode()
: null;
self::handleConnectionReport($data, $result, $url, $http_code);

return $result;
}

/**
* Add the API request result to connection reports. Never breaks the API call.
*
* @param array $data
* @param mixed $result
* @param string $url
* @param int|null $http_code
*/
private static function handleConnectionReport($data, $result, $url, $http_code)
{
global $apbct;

if ( ! $apbct instanceof State || ! defined('APBCT_TBL_CONNECTION_REPORTS') ) {
return;
}

try {
$apbct->getConnectionReports()->handleApiRequest(
isset($data['method_name']) ? $data['method_name'] : 'unknown',
$data,
$result,
$url,
$http_code
);
} catch ( \Throwable $e ) {
// Reporting failures must not affect the API request result
return;
}
}
}
Loading
Loading