\Drupal\strata\Restore RestoreAudit

The record of who restored what, when, and what it did.

One of the two tables nothing in the bucket can reproduce, and the reason an uninstall exports before dropping. The bucket records what the site looked like; this records what someone did to it.

A row is written BEFORE the restore runs, with the outcome pending and the plan already in it. A restore that crashes half way therefore leaves a row saying it started and never finished, which is the state an operator needs to see. Writing the row afterwards would mean the only restores on record are the ones that worked.

Summary

Methods
Properties
Constants
__construct
open
close
refuse
recent
get
unfinished
No public properties found
TABLE
PENDING
SUCCEEDED
FAILED
REFUSED
LOGICAL
PHYSICAL
No protected methods found
No protected properties found
No protected constants found
No private methods found
database
No private constants found

Constant

TABLE

TABLE = 'strata_restore_log'

The table restores are recorded in.

PENDING

PENDING = 'pending'

Recorded while a restore is in flight.

SUCCEEDED

SUCCEEDED = 'succeeded'

Recorded when a restore finished and wrote what it planned to.

FAILED

FAILED = 'failed'

Recorded when a restore started and did not finish.

REFUSED

REFUSED = 'refused'

Recorded when a restore declined to start.

LOGICAL

LOGICAL = 'logical'

A restore that writes entities and config in place, with the site up.

PHYSICAL

PHYSICAL = 'physical'

A restore that replaces whole tables, with the site in maintenance mode.

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

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

Constructs an audit.

Parameters

\Drupal\Core\Database\Connection $database

The database.

Returns

mixed —

open()

open(\Drupal\strata\Restore\RestorePlan  $plan, string  $scope, string  $mode = \self::LOGICAL, int|null  $actor = null, string|null  $snapshot = null) : int

Opens a row for a restore that is about to run.

Parameters

\Drupal\strata\Restore\RestorePlan $plan

What the restore intends to do.

string $scope

What it was scoped to, as the operator expressed it.

string $mode

Either RestoreAudit::LOGICAL or RestoreAudit::PHYSICAL.

int|null $actor

Drupal user id running it, or NULL for an unattended run.

string|null $snapshot

Commit taken before the restore so it can be undone, or NULL when none was taken.

Returns

int —

The row id, to close the entry with.

close()

close(int  $id, \Drupal\strata\Restore\RestoreResult  $result) : void

Closes a row with what the restore actually did.

Parameters

int $id

The row id from RestoreAudit::open().

\Drupal\strata\Restore\RestoreResult $result

What happened.

Returns

void —

refuse()

refuse(\Drupal\strata\Restore\RestorePlan  $plan, string  $scope, string  $reason, string  $mode = \self::LOGICAL, int|null  $actor = null) : int

Records a restore that declined to start.

Parameters

\Drupal\strata\Restore\RestorePlan $plan

What it would have done.

string $scope

What it was scoped to.

string $reason

Why it refused.

string $mode

Either RestoreAudit::LOGICAL or RestoreAudit::PHYSICAL.

int|null $actor

Drupal user id, or NULL.

Returns

int —

The row id.

recent()

recent(int  $limit = 50) : list<array<string,mixed>>

Restores in reverse order, newest first.

Parameters

int $limit

Most rows to return.

Returns

list> —

The rows.

get()

get(int  $id) : array<string,mixed>|null

One row.

Parameters

int $id

The row id.

Returns

array|null —

The row, or NULL when it is not there.

unfinished()

unfinished() : list<array<string,mixed>>

Restores that started and never finished.

What a status page shows as needing attention: a pending row that is not this request's is a restore that died, and the site may be half rolled back.

Returns

list> —

The rows, oldest first.