RecordHistory

class \TYPO3\CMS\Backend\History\RecordHistory

Class for fetching the history entries of a record (and if it is a page, its sub elements as well)

Table of Contents

Properties

$element  : string
Element reference, syntax [tablename]:[uid]
$lastHistoryEntry  : int
sys_history uid which is selected
$maxSteps  : int
Maximum number of sys_history steps to show.
$pageAccessCache  : array
Internal cache
$showSubElements  : bool
On a pages table - show sub elements as well.

Methods

__construct()  : mixed
Constructor to define which element to work on - can be overridden with "setLastHistoryEntryNumber"
findEventsForCorrelation()  : array
findEventsForRecord()  : array
Queries the DB and prepares the results Resolving a WSOL of the UID and checking permissions is explicitly not part of this method
findEventsForScope()  : array
All entries written during one operation, no matter which record they belong to. They share the scope of their correlation id, while the subject differs per record, so an operation can only be looked up by the prefix the whole scope has in common.
getChangeLog()  : array
Creates change log including sub-elements
getCreationInformationForRecord()  : array|null
Fetches the history entry for an ADD/creation action for a specific record.
getDiff()  : array
Creates a diff between the current version of the records and the selected version
getElementInformation()  : array
An array (0 = tablename, 1 = uid) or empty array if no element is set
getElementString()  : string
getHistoryDataForRecord()  : array
Gets history and delete/insert data from sys_log and sys_history
getLastHistoryEntryNumber()  : int
getScopeOfEvent()  : string|null
The scope an entry was written in, or null for entries that carry no correlation id at all.
getTranslations()  : array{page: int, elements: array{element: string, language: int}[]}|null
Compile a list of record history elements that belong to the same translation root.
getUserIdFromDeleteActionForRecord()  : int
Get the user uid of the user who deleted the record for the given table
setLastHistoryEntryNumber()  : void
If a specific history entry is selected, then the relevant element is resolved for that.
setMaxSteps()  : void
Define the maximum amount of history entries to be shown. Beware of side-effects when using "showSubElements" as well.
setShowSubElements()  : void
Defines to show the history of a specific record or its subelements (when it's a page) as well.
addWorkspaceRestriction()  : void
Entries of a workspace are only visible to a user working in that very workspace.
getBackendUser()  : BackendUserAuthentication
getHistoryData()  : array
Fetches the history data of a record + includes subelements if this is from a page
getHistoryEntry()  : array
Resolve tablename + record uid from sys_history UID
getQueryBuilder()  : QueryBuilder
getTcaSchema()  : TcaSchema|null
getTcaSchemaFactory()  : TcaSchemaFactory
hasPageAccess()  : bool
Determines whether user has access to a page.
hasTableAccess()  : bool
Determines whether user has access to a table.
prepareEventDataFromQueryBuilder()  : array
resolveElement()  : int
Convert input element reference to workspace version if any.
sanitizeElementValue()  : string
Sanitizes the values for the expected disposal.
updateCurrentElement()  : void

Properties

$element

Element reference, syntax [tablename]:[uid]

protected string $element = ''

$lastHistoryEntry

sys_history uid which is selected

protected int $lastHistoryEntry = 0

$maxSteps

Maximum number of sys_history steps to show.

protected int $maxSteps = 20

$pageAccessCache

Internal cache

protected array $pageAccessCache = []

$showSubElements

On a pages table - show sub elements as well.

protected bool $showSubElements = true

Methods

__construct()

Constructor to define which element to work on - can be overridden with "setLastHistoryEntryNumber"

public __construct([string $element = '' ]) : mixed

Parameters

$element : string = ''

in the form of "tablename:uid"

findEventsForCorrelation()

public findEventsForCorrelation(string $correlationId) : array

Parameters

$correlationId : string

Return values

array

findEventsForRecord()

Queries the DB and prepares the results Resolving a WSOL of the UID and checking permissions is explicitly not part of this method

public findEventsForRecord(string $table, int $uid[, int $limit = 0 ][, int|null $minimumUid = null ]) : array

Parameters

$table : string
$uid : int
$limit : int = 0
$minimumUid : int|null = null

Return values

array

findEventsForScope()

All entries written during one operation, no matter which record they belong to. They share the scope of their correlation id, while the subject differs per record, so an operation can only be looked up by the prefix the whole scope has in common.

public findEventsForScope(string $scope[, int $limit = 0 ]) : array

The result is limited to what the user may see: one operation can span tables and pages, and a record history must not become a way around table or page permissions.

Parameters

$scope : string
$limit : int = 0

Return values

array

getChangeLog()

Creates change log including sub-elements

public getChangeLog() : array

Return values

array

getCreationInformationForRecord()

Fetches the history entry for an ADD/creation action for a specific record.

public getCreationInformationForRecord(string $table, array $record) : array|null

Parameters

$table : string
$record : array

Return values

array|null

getDiff()

Creates a diff between the current version of the records and the selected version

public getDiff(array $changeLog) : array

Parameters

$changeLog : array

Return values

array —

Diff for many elements

getElementInformation()

An array (0 = tablename, 1 = uid) or empty array if no element is set

public getElementInformation() : array

Return values

array

getElementString()

public getElementString() : string

Return values

string —

named "tablename:uid"

getHistoryDataForRecord()

Gets history and delete/insert data from sys_log and sys_history

public getHistoryDataForRecord(string $table, int $uid[, int|null $lastHistoryEntry = null ]) : array

Parameters

$table : string

DB table name

$uid : int

UID of record

$lastHistoryEntry : int|null = null

the highest entry to be fetched

Return values

array —

Array of history data of the record

getLastHistoryEntryNumber()

public getLastHistoryEntryNumber() : int

Return values

int

getScopeOfEvent()

The scope an entry was written in, or null for entries that carry no correlation id at all.

public getScopeOfEvent(array $event) : string|null

Parameters

$event : array

Return values

string|null

getTranslations()

Compile a list of record history elements that belong to the same translation root.

public getTranslations(string $element) : array{page: int, elements: array{element: string, language: int}[]}|null

Parameters

$element : string

Return values

array{page: int, elements: array{element: string, language: int}[]}|null

getUserIdFromDeleteActionForRecord()

Get the user uid of the user who deleted the record for the given table

public getUserIdFromDeleteActionForRecord(string $table, int $uid) : int

Parameters

$table : string
$uid : int

Return values

int

setLastHistoryEntryNumber()

If a specific history entry is selected, then the relevant element is resolved for that.

public setLastHistoryEntryNumber(int $lastHistoryEntry) : void

Parameters

$lastHistoryEntry : int

setMaxSteps()

Define the maximum amount of history entries to be shown. Beware of side-effects when using "showSubElements" as well.

public setMaxSteps(int $maxSteps) : void

Parameters

$maxSteps : int

setShowSubElements()

Defines to show the history of a specific record or its subelements (when it's a page) as well.

public setShowSubElements(bool $showSubElements) : void

Parameters

$showSubElements : bool

addWorkspaceRestriction()

Entries of a workspace are only visible to a user working in that very workspace.

protected addWorkspaceRestriction(QueryBuilder $queryBuilder) : void

Parameters

$queryBuilder : QueryBuilder

getHistoryData()

Fetches the history data of a record + includes subelements if this is from a page

protected getHistoryData(string $table, int $uid[, bool|null $includeSubEntries = null ][, int $lastHistoryEntry = null ]) : array

Parameters

$table : string
$uid : int
$includeSubEntries : bool|null = null
$lastHistoryEntry : int = null

the highest entry to be evaluated

Return values

array

getHistoryEntry()

Resolve tablename + record uid from sys_history UID

protected getHistoryEntry(int $lastHistoryEntry) : array

Parameters

$lastHistoryEntry : int

Return values

array

hasPageAccess()

Determines whether user has access to a page.

protected hasPageAccess(string $table, int $uid) : bool

Parameters

$table : string
$uid : int

Return values

bool

hasTableAccess()

Determines whether user has access to a table.

protected hasTableAccess(string $table) : bool

Parameters

$table : string

Return values

bool

prepareEventDataFromQueryBuilder()

protected prepareEventDataFromQueryBuilder(QueryBuilder $queryBuilder) : array

Parameters

$queryBuilder : QueryBuilder

Return values

array

resolveElement()

Convert input element reference to workspace version if any.

protected resolveElement(string $table, int $uid) : int

Parameters

$table : string

Table of input element

$uid : int

UID of record

Return values

int —

converted UID of record

sanitizeElementValue()

Sanitizes the values for the expected disposal.

protected sanitizeElementValue(string $value) : string

Invalid values will be converted to an empty string.

Parameters

$value : string

the value of the element value

Return values

string

updateCurrentElement()

protected updateCurrentElement() : void
On this page