Documentation

MySqlTermScheduleRepository
in package
implements TermScheduleRepositoryInterface

FinalYes

MySQL persistence for FSRS scheduling state.

term_schedule and review_log carry no user column of their own — they are keyed by WoID, and words.WoUsID is the owner. QueryBuilder's automatic user scope only covers tables in its table→column map, so every statement here joins words and applies the scope explicitly. Skipping that would let a caller read or write another user's scheduling state by WoID alone.

Table of Contents

Interfaces

TermScheduleRepositoryInterface
Persistence for FSRS memory state and review history.

Constants

DATETIME_FORMAT  : mixed = 'Y-m-d H:i:s'

Methods

countDue()  : int
Number of terms whose next review is due at or before now.
find()  : MemoryState|null
Load a term's memory state, or null if it has never been graded.
findOrSeed()  : MemoryState|null
Load a term's memory state, falling back to a seed derived from its legacy WoStatus/WoStatusChanged when it has never been graded.
saveReview()  : void
Persist memory state and append the matching review_log row.
appendUserScope()  : string
Append the words-table user scope to $params and return the SQL fragment.
ownsWord()  : bool
Whether the current user owns this term.

Constants

Methods

countDue()

Number of terms whose next review is due at or before now.

public countDue([int|null $languageId = null ]) : int
Parameters
$languageId : int|null = null

Restrict to one language, or null for all

Return values
int

find()

Load a term's memory state, or null if it has never been graded.

public find(int $wordId) : MemoryState|null

Returns null for a term the current user does not own.

Parameters
$wordId : int
Return values
MemoryState|null

findOrSeed()

Load a term's memory state, falling back to a seed derived from its legacy WoStatus/WoStatusChanged when it has never been graded.

public findOrSeed(int $wordId) : MemoryState|null

Returns null for a term that does not exist, is not owned by the current user, or whose status is not schedulable (98 ignored / 99 well-known).

Parameters
$wordId : int
Return values
MemoryState|null

saveReview()

Persist memory state and append the matching review_log row.

public saveReview(int $wordId, SchedulingResult $result, Rating $rating, int $stateBefore) : void

Both writes happen together: the log is the audit trail for the state, so a state change without its log entry would corrupt any later parameter optimisation.

Parameters
$wordId : int
$result : SchedulingResult
$rating : Rating
$stateBefore : int

appendUserScope()

Append the words-table user scope to $params and return the SQL fragment.

private appendUserScope(array<int, int|string> &$params) : string

Mirrors ReviewConfiguration::appendUserScope — inlined for the same reason, to keep Psalm's int|string element type on $params.

Parameters
$params : array<int, int|string>

Reference to params array

Return values
string

ownsWord()

Whether the current user owns this term.

private ownsWord(int $wordId) : bool
Parameters
$wordId : int
Return values
bool
On this page

Search results