\Drupal\strata\Health DatabaseHealthLedger

The ledger a site runs on.

Findings outlive the request that noticed them, so a verify pass on cron leaves something for the health dashboard to show and something the repair ladder can escalate from. This is one of the two tables an uninstall exports before dropping, because nothing in the bucket can reproduce it: the bucket records what the site looks like, not what went wrong reaching it.

A row is inserted once per code and scope and given a fresh timestamp when the same symptom is seen again, so a check that fires every cron run produces one open row rather than one row per run. What the dashboard sorts by is how many scopes a code covers, which is the difference between one broken frame and a broken bucket.

Summary

Methods
Properties
Constants
__construct
record
open
resolve
purge
rungFor
setRung
summary
No public properties found
TABLE
No protected methods found
No protected properties found
No protected constants found
startingRung
now
database
No private constants found

Constant

TABLE

TABLE = 'strata_health'

The table findings live in.

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

__construct(\Drupal\Core\Database\Connection  $database) : mixed

Constructs a ledger.

Parameters

\Drupal\Core\Database\Connection $database

The database.

Returns

mixed —

record()

record(\Drupal\strata\Health\Finding  $finding) : void

Records one finding.

Parameters

\Drupal\strata\Health\Finding $finding

What a tripwire noticed.

Returns

void —

open()

open() : \Drupal\strata\Health\Finding[]

Every finding still held, oldest first.

Returns

\Drupal\strata\Health\Finding[] —

The open findings, empty when nothing is outstanding.

resolve()

resolve(string  $code, string  $scope) : int

Clears the findings for one code and scope.

Parameters

string $code

The finding code.

string $scope

The exact scope that has been dealt with.

Returns

int —

How many findings were cleared.

purge()

purge(int  $olderThan) : int

Drops findings recorded before a point in time.

Only resolved rows are dropped. An open finding is the reason someone is looking at the dashboard, and age is not evidence that it stopped being true.

Parameters

int $olderThan

Unix timestamp; findings recorded strictly before this are dropped.

Returns

int —

How many findings were dropped.

rungFor()

rungFor(string  $code) : string

The rung a code currently sits at.

The rung is stored per row but is a property of the CODE, so the answer is the highest rung any row for that code carries. A code with nothing recorded sits at the bottom of the ladder.

Parameters

string $code

The finding code.

Returns

string —

A rung name from RepairLadder::RUNGS.

setRung()

setRung(string  $code, string  $rung) : void

Moves a code to a rung.

Parameters

string $code

The finding code.

string $rung

A rung name from RepairLadder::RUNGS.

Throws

\InvalidArgumentException

When the rung is not one the ladder knows. Storing a typo would park the code where RepairLadder::isAutomatic() refuses it forever.

Returns

void —

summary()

summary() : list<array{code: string, severity: int, rung: string, scopes: int, newest: int}>

How many times each open code has been seen, worst first.

What the health dashboard lists. Grouped in the database rather than by loading every row, since a site that has been broken for a week can hold a lot of them.

Returns

list

One row per open code.

startingRung()

startingRung(\Drupal\strata\Health\Finding  $finding) : string

The rung a finding lands on.

A code that has already been escalated stays where it is. Otherwise the severity decides, which is what puts a critical finding straight at quarantine instead of walking it up the ladder one cron run at a time while the site cannot restore.

Parameters

\Drupal\strata\Health\Finding $finding

The finding being recorded.

Returns

string —

The rung name.

now()

now() : int

The current time.

Returns

int —

Unix seconds.