| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Exception thrown by getRedirectsForView() / getRedirectsForViewCount() when the |
| 9 |
* underlying SQL query fails or times out. Carries a structured diagnostics |
| 10 |
* payload (table counts, indexes, engine + collation, canonical_url backfill |
| 11 |
* state, MySQL/MariaDB version, EXPLAIN output, redacted query) so the AJAX |
| 12 |
* error path in ViewUpdater can surface evidence to plugin admins and write it |
| 13 |
* to the debug log without a follow-up debug zip from the user. |
| 14 |
* |
| 15 |
* The diagnostics array is intentionally schema-loose: every diagnostic |
| 16 |
* sub-query in captureViewQueryFailureDiagnostics() is wrapped in try/catch so |
| 17 |
* one failed probe never blocks the others. Consumers should treat any key as |
| 18 |
* potentially absent or string-typed (an error marker) and render accordingly. |
| 19 |
*/ |
| 20 |
class ABJ_404_Solution_ViewQueryFailureException extends Exception { |
| 21 |
|
| 22 |
/** @var array<string, mixed> */ |
| 23 |
private $diagnostics; |
| 24 |
|
| 25 |
/** |
| 26 |
* @param string $message |
| 27 |
* @param array<string, mixed> $diagnostics |
| 28 |
* @param Throwable|null $previous |
| 29 |
*/ |
| 30 |
public function __construct(string $message, array $diagnostics = [], ?Throwable $previous = null) { |
| 31 |
parent::__construct($message, 0, $previous); |
| 32 |
$this->diagnostics = $diagnostics; |
| 33 |
} |
| 34 |
|
| 35 |
/** @return array<string, mixed> */ |
| 36 |
public function getDiagnostics(): array { |
| 37 |
return $this->diagnostics; |
| 38 |
} |
| 39 |
} |
| 40 |
|