class DatabaseVersioner implements VersionerInterface

Records asset revisions one row at a time, so several instances can record different assets at once.

{\Flarum\Frontend\Compiler\FileVersioner} keeps the whole map in a single JSON value, which means every write is a read-modify-write of all of it: a writer carrying a snapshot taken before someone else's write silently erases that write when it saves. Measured across two ECS tasks writing twenty assets each, half the writes were lost; across six local processes, 83% were. Because {[\Flarum\Frontend\Compiler\RevisionCompiler::getUrl()}](../../../Flarum/Frontend/Compiler/RevisionCompiler.html) only recompiles when a revision is *missing*, a lost revision is not noticed — it simply stays wrong until the next admin action. Here each revision is its own row, keyed by the asset's path, so a write touches nothing else and there is no shared value to clobber. Reads are memoised for the lifetime of the instance, matching FileVersioner: rendering a page reads the map around thirty times and individual revisions around sixty-five times through one shared instance, and every one of those would otherwise be a query.

Constants

TABLE

Methods

__construct(ConnectionInterface $database)

No description

void
putRevision(string $file, string|null $revision)

Record the current revision of a file, or forget it when null.

void
deferWrites()

Collect writes until {flushWrites()} instead of storing each one as it arrives, so a rebuild that records every asset in turn can store them together.

__destruct()

A batch left open — a caller that never flushed, or a rebuild that threw past its own flush — must still be stored. Reads are answered from the memo while a batch is open, so nothing else would notice the omission until the revisions were missing on the next request.

void
flushWrites()

Store anything {deferWrites()} collected, and stop deferring.

string|null
getRevision(string $file)

The recorded revision, or null when there is none.

array
allRevisions()

No description

Details

__construct(ConnectionInterface $database)

Parameters

ConnectionInterface $database

void putRevision(string $file, string|null $revision)

Record the current revision of a file, or forget it when null.

Parameters

string $file
string|null $revision

Return Value

void

void deferWrites()

Collect writes until {flushWrites()} instead of storing each one as it arrives, so a rebuild that records every asset in turn can store them together.

Buffered writes are still visible to this instance's own reads, and a read of anything buffered stores the buffer first, so nothing can observe a revision that has been recorded but not saved. An implementation with nothing to gain from batching may treat both methods as no-ops.

Return Value

void

__destruct()

A batch left open — a caller that never flushed, or a rebuild that threw past its own flush — must still be stored. Reads are answered from the memo while a batch is open, so nothing else would notice the omission until the revisions were missing on the next request.

void flushWrites()

Store anything {deferWrites()} collected, and stop deferring.

Safe to call when nothing was deferred.

Return Value

void

string|null getRevision(string $file)

The recorded revision, or null when there is none.

Parameters

string $file

Return Value

string|null

array allRevisions()

Return Value

array