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
$rollbackFields  : string
Either "table:uid" or "table:uid:field" to know which data should be rolled back
$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
getChangeLog()  : array
Creates change log including sub-elements
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
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.
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
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.
sanitizeRollbackFieldsValue()  : string
Evaluates if the rollback field is correct
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 = []

$rollbackFields

Either "table:uid" or "table:uid:field" to know which data should be rolled back

protected string $rollbackFields = ''

$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 = '' ][, string $rollbackFields = '' ]) : mixed

Parameters

$element : string = ''

in the form of "tablename:uid"

$rollbackFields : string = ''

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

getChangeLog()

Creates change log including sub-elements

public getChangeLog() : array

Return values

array

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

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

getHistoryData()

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

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

Parameters

$table : string
$uid : int
$includeSubEntries : bool = null
$lastHistoryEntry : int|null = 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

sanitizeRollbackFieldsValue()

Evaluates if the rollback field is correct

protected sanitizeRollbackFieldsValue(string $value) : string

Parameters

$value : string

Return values

string

updateCurrentElement()

protected updateCurrentElement() : void
On this page