| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Coordinates frequent checkpoint writes from request-safe boundaries. |
| 9 |
* |
| 10 |
* Directory resolution belongs to the checkpoint logger, while the low-level |
| 11 |
* writer owns the request cache and append path. Keeping their coordination |
| 12 |
* here prevents either collaborator from depending back on the other. |
| 13 |
*/ |
| 14 |
final class ABJ_404_Solution_AjaxCheckpointBoundaryWriter { |
| 15 |
|
| 16 |
/** |
| 17 |
* Resolve once, then reuse the cached result for the rest of the request. |
| 18 |
* |
| 19 |
* An empty directory is a cached failure: retrying WordPress filters can |
| 20 |
* recurse into the same database boundary being traced. Callbacks already |
| 21 |
* executing inside wpdb must use the low-level writer with a previously |
| 22 |
* resolved directory instead. |
| 23 |
* |
| 24 |
* @param array<string, mixed> $fields |
| 25 |
*/ |
| 26 |
public static function record( |
| 27 |
string $requestId, |
| 28 |
string $event, |
| 29 |
array $fields = array() |
| 30 |
): void { |
| 31 |
if (!ABJ_404_Solution_AjaxFrequentCheckpointWriter::hasResolvedDirectoryForRequest( |
| 32 |
$requestId |
| 33 |
)) { |
| 34 |
ABJ_404_Solution_AjaxCheckpointLogger::recordFrequent( |
| 35 |
$requestId, |
| 36 |
$event, |
| 37 |
$fields |
| 38 |
); |
| 39 |
return; |
| 40 |
} |
| 41 |
ABJ_404_Solution_AjaxFrequentCheckpointWriter::append( |
| 42 |
$requestId, |
| 43 |
$event, |
| 44 |
$fields, |
| 45 |
ABJ_404_Solution_AjaxFrequentCheckpointWriter::resolvedDirectoryForRequest( |
| 46 |
$requestId |
| 47 |
), |
| 48 |
true |
| 49 |
); |
| 50 |
} |
| 51 |
} |
| 52 |
|