PluginProbe
404 Solution / 4.3.0
404 Solution v4.3.0
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 / database / DatabaseErrorRecoveryInterface.php

DatabaseErrorRecoveryInterface.php in 404 Solution 4.3.0, at includes/database/DatabaseErrorRecoveryInterface.php

72 lines 2.3 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 * Error classification + self-healing recovery: classify infrastructure
9 * errors, detect OOM, REPAIR TABLE for crashed tables, fix duplicate
10 * auto_increment IDs, recover from collation mismatches, and the test seam
11 * for the injected clock.
12 *
13 * Legacy view-build staged-failure routing (the 'resumable'/'skip'/'halt'
14 * /'rethrow' classifier) intentionally lives outside this database-layer
15 * interface: those tokens are not database recovery vocabulary.
16 */
17 interface ABJ_404_Solution_DatabaseErrorRecoveryInterface {
18
19 /**
20 * Classify an error as infrastructure (server-side) and handle it.
21 *
22 * @param string $errorText
23 * @return bool True if handled as infrastructure error.
24 */
25 public function classifyAndHandleInfrastructureError(string $errorText): bool;
26
27 /**
28 * @param string $errorText
29 * @return bool
30 */
31 public function isOutOfMemoryError(string $errorText): bool;
32
33 /**
34 * Attempt REPAIR TABLE for crashed or corrupted-key-file tables.
35 *
36 * @param string $errorMessage The MySQL error string.
37 * @return void
38 */
39 public function repairTable(string $errorMessage): void;
40
41 /**
42 * Attempt to fix duplicate auto_increment IDs caused by ALTER TABLE resequencing.
43 *
44 * @param string $errorMessage The MySQL error string.
45 * @param string $sqlThatWasRun The SQL that triggered the error.
46 * @return void
47 */
48 public function repairDuplicateIDs(string $errorMessage, string $sqlThatWasRun): void;
49
50 /**
51 * Auto-recover from collation mismatches by running correctCollations()
52 * then retrying the original query.
53 *
54 * @param string $query The SQL query to retry.
55 * @param array<string, mixed> $result Passed by reference; updated on successful retry.
56 * @param bool $producesRows Whether the query returns result rows.
57 * @param string $resultType wpdb output type (ARRAY_A or OBJECT).
58 * @return void
59 */
60 public function recoverFromCollationMismatchAndRetry(
61 string $query, array &$result, bool $producesRows, string $resultType
62 ): void;
63
64 /**
65 * Inject the clock instance for testability.
66 *
67 * @param ABJ_404_Solution_Clock $clock
68 * @return void
69 */
70 public function setClock(ABJ_404_Solution_Clock $clock): void;
71 }
72