PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / diagnostics / AjaxCheckpointBoundaryWriter.php

AjaxCheckpointBoundaryWriter.php in 404 Solution trunk, at includes/diagnostics/AjaxCheckpointBoundaryWriter.php

52 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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