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 / DatabaseInfrastructureErrorTaxonomy.php

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

89 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 /**
7 * Composite database infrastructure error taxonomy.
8 *
9 * Holds three focused subsystem taxonomies and exposes them via accessor
10 * methods. Owns no classification logic of its own; the union aggregator
11 * `isInfrastructureSqlError()` is the only behavior at this layer.
12 *
13 * connectivity() - transport, timeout, packet, deadlock failures
14 * (DatabaseConnectivityErrorTaxonomy)
15 * hostState() - disk, quota, read-only, oom, access, galera,
16 * set-statement privilege failures
17 * (DatabaseHostStateErrorTaxonomy)
18 * schema() - crashed/missing tables, view-build churn, invalid
19 * data, collation failures
20 * (DatabaseSchemaErrorTaxonomy)
21 *
22 * No database, transient, notice, or logging side effects.
23 */
24
25 require_once __DIR__ . '/DatabaseConnectivityErrorTaxonomy.php';
26 require_once __DIR__ . '/DatabaseHostStateErrorTaxonomy.php';
27 require_once __DIR__ . '/DatabaseSchemaErrorTaxonomy.php';
28
29 // allow-no-test-found: covered through DatabaseErrorClassifier facade by tests/SuppressWpdbErrorsTest.php and tests/DataAccessRetrySemanticsTest.php / tests/DataAccessInfraErrorNoticeLifecycleTest.php
30 class ABJ_404_Solution_DatabaseInfrastructureErrorTaxonomy {
31
32 /** @var ABJ_404_Solution_DatabaseConnectivityErrorTaxonomy */
33 private $connectivity;
34
35 /** @var ABJ_404_Solution_DatabaseHostStateErrorTaxonomy */
36 private $hostState;
37
38 /** @var ABJ_404_Solution_DatabaseSchemaErrorTaxonomy */
39 private $schema;
40
41 /**
42 * @param ABJ_404_Solution_Functions $functions
43 */
44 public function __construct($functions) {
45 $this->connectivity = new ABJ_404_Solution_DatabaseConnectivityErrorTaxonomy($functions);
46 $this->hostState = new ABJ_404_Solution_DatabaseHostStateErrorTaxonomy($functions);
47 $this->schema = new ABJ_404_Solution_DatabaseSchemaErrorTaxonomy($functions);
48 }
49
50 /** @return ABJ_404_Solution_DatabaseConnectivityErrorTaxonomy */
51 public function connectivity(): ABJ_404_Solution_DatabaseConnectivityErrorTaxonomy {
52 return $this->connectivity;
53 }
54
55 /** @return ABJ_404_Solution_DatabaseHostStateErrorTaxonomy */
56 public function hostState(): ABJ_404_Solution_DatabaseHostStateErrorTaxonomy {
57 return $this->hostState;
58 }
59
60 /** @return ABJ_404_Solution_DatabaseSchemaErrorTaxonomy */
61 public function schema(): ABJ_404_Solution_DatabaseSchemaErrorTaxonomy {
62 return $this->schema;
63 }
64
65 /**
66 * Union aggregator: true when the error text matches any infrastructure
67 * failure mode the plugin should react to (notice-state, retry, repair,
68 * or write-block).
69 *
70 * @param string $errorText
71 * @return bool
72 */
73 public function isInfrastructureSqlError(string $errorText): bool {
74 return $this->hostState->isDiskFullError($errorText)
75 || $this->hostState->isReadOnlyError($errorText)
76 || $this->hostState->isQuotaLimitError($errorText)
77 || $this->schema->isInvalidDataError($errorText)
78 || $this->schema->isCollationError($errorText)
79 || $this->schema->isMissingPluginTableError($errorText)
80 || $this->schema->isIncorrectKeyFileError($errorText)
81 || $this->schema->isCrashedTableError($errorText)
82 || $this->connectivity->isDeadlockOrLockTimeoutError($errorText)
83 || $this->hostState->isGaleraConflictError($errorText)
84 || $this->connectivity->isTransientConnectionError($errorText)
85 || $this->connectivity->isQueryTimeoutError($errorText)
86 || $this->hostState->isAccessDeniedError($errorText);
87 }
88 }
89