‪TYPO3CMS  10.4
TYPO3\CMS\Backend\History\RecordHistory Class Reference
Inheritance diagram for TYPO3\CMS\Backend\History\RecordHistory:
TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait

Public Member Functions

 __construct ($element='', $rollbackFields='')
 
 setLastHistoryEntry (int $lastHistoryEntryNumber)
 
 setLastHistoryEntryNumber (int $lastHistoryEntry)
 
 getLastHistoryEntryNumber ()
 
 setMaxSteps (int $maxSteps)
 
 setShowSubElements (bool $showSubElements)
 
 createChangeLog ()
 
 getChangeLog ()
 
bool shouldPerformRollback ()
 
array bool getElementData ()
 
array getElementInformation ()
 
string getElementString ()
 
 performRollback ()
 
array createMultipleDiff ()
 
array getDiff (array $changeLog)
 
array getHistoryDataForRecord (string $table, int $uid, int $lastHistoryEntry=null)
 
array findEventsForRecord (string $table, int $uid, int $limit=0, int $minimumUid=null)
 
 findEventsForCorrelation (string $correlationId)
 
 legacyUpdates ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait
mixed __call (string $methodName, array $arguments)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
bool __isset (string $propertyName)
 
mixed __get (string $propertyName)
 
 __set (string $propertyName, $propertyValue)
 
 __unset (string $propertyName)
 

Protected Member Functions

array getHistoryData (string $table, int $uid, bool $includeSubEntries=null, int $lastHistoryEntry=null)
 
int resolveElement (string $table, int $uid)
 
array getHistoryEntry (int $lastHistoryEntry)
 
 prepareEventDataFromQueryBuilder (QueryBuilder $queryBuilder)
 
bool hasPageAccess ($table, $uid)
 
string sanitizeElementValue ($value)
 
string sanitizeRollbackFieldsValue ($value)
 
bool hasTableAccess ($table)
 
 getBackendUser ()
 
 getQueryBuilder ()
 
 updateCurrentElement ()
 

Protected Attributes

int $maxSteps = 20
 
bool $showSubElements = true
 
string $element
 
int $lastHistoryEntry = 0
 
array $changeLog = array( )
 
array $pageAccessCache = array( )
 
string $rollbackFields = ''
 

Private Attributes

string[] $deprecatedPublicMethods
 
string[] $deprecatedPublicProperties
 

Detailed Description

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

Definition at line 32 of file RecordHistory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\History\RecordHistory::__construct (   $element = '',
  $rollbackFields = '' 
)

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

Parameters
string$element‪in the form of "tablename:uid"
string$rollbackFields

Definition at line 93 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\sanitizeElementValue(), and TYPO3\CMS\Backend\History\RecordHistory\sanitizeRollbackFieldsValue().

Member Function Documentation

◆ createChangeLog()

TYPO3\CMS\Backend\History\RecordHistory::createChangeLog ( )

Creates change log including sub-elements, filling $this->changeLog

Deprecated:
‪since TYPO3 v10.1, will be removed in TYPO3 v11.0, use getChangeLog() instead.

Definition at line 152 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getChangeLog().

◆ createMultipleDiff()

array TYPO3\CMS\Backend\History\RecordHistory::createMultipleDiff ( )

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

Returns
‪array Diff for many elements
Deprecated:
‪since TYPO3 v10.1, will be removed in TYPO3 v11.0, use getDiff() instead.

Definition at line 235 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getDiff().

◆ findEventsForCorrelation()

TYPO3\CMS\Backend\History\RecordHistory::findEventsForCorrelation ( string  $correlationId)

◆ findEventsForRecord()

array TYPO3\CMS\Backend\History\RecordHistory::findEventsForRecord ( string  $table,
int  $uid,
int  $limit = 0,
int  $minimumUid = null 
)

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

Parameters
string$table
int$uid
int$limit
int$minimumUid
Returns
‪array

Definition at line 419 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getQueryBuilder(), and TYPO3\CMS\Backend\History\RecordHistory\prepareEventDataFromQueryBuilder().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord().

◆ getBackendUser()

TYPO3\CMS\Backend\History\RecordHistory::getBackendUser ( )
protected

◆ getChangeLog()

TYPO3\CMS\Backend\History\RecordHistory::getChangeLog ( )

Creates change log including sub-elements @noinspection GetSetMethodCorrectnessInspection @TODO: In v11 remove the property $this->changeLog and the @noinspection above

Definition at line 162 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getHistoryData().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\createChangeLog(), TYPO3\CMS\Backend\History\RecordHistory\legacyUpdates(), and TYPO3\CMS\Backend\History\RecordHistory\performRollback().

◆ getDiff()

array TYPO3\CMS\Backend\History\RecordHistory::getDiff ( array  $changeLog)

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

Parameters
array$changeLog
Returns
‪array Diff for many elements

Definition at line 246 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$changeLog, and TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore\ACTION_MODIFY.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\createMultipleDiff(), and TYPO3\CMS\Backend\History\RecordHistory\performRollback().

◆ getElementData()

array bool TYPO3\CMS\Backend\History\RecordHistory::getElementData ( )

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

Returns
‪array|bool
Deprecated:
‪since TYPO3 v10.1, will be removed in TYPO3 v11.0. Use getElementInformation() instead.

Definition at line 187 of file RecordHistory.php.

◆ getElementInformation()

array TYPO3\CMS\Backend\History\RecordHistory::getElementInformation ( )

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

Returns
‪array

Definition at line 196 of file RecordHistory.php.

◆ getElementString()

string TYPO3\CMS\Backend\History\RecordHistory::getElementString ( )
Returns
‪string named "tablename:uid"

Definition at line 204 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$element.

◆ getHistoryData()

array TYPO3\CMS\Backend\History\RecordHistory::getHistoryData ( string  $table,
int  $uid,
bool  $includeSubEntries = null,
int  $lastHistoryEntry = null 
)
protected

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

Parameters
string$table
int$uid
bool$includeSubEntries
int$lastHistoryEntry‪the highest entry to be evaluated
Returns
‪array

Definition at line 298 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord(), and TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getChangeLog().

◆ getHistoryDataForRecord()

array TYPO3\CMS\Backend\History\RecordHistory::getHistoryDataForRecord ( string  $table,
int  $uid,
int  $lastHistoryEntry = null 
)

Gets history and delete/insert data from sys_log and sys_history

Parameters
string$table‪DB table name
int$uid‪UID of record
int$lastHistoryEntry‪the highest entry to be fetched
Returns
‪array Array of history data of the record

Definition at line 354 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, TYPO3\CMS\Backend\History\RecordHistory\findEventsForRecord(), TYPO3\CMS\Backend\History\RecordHistory\hasPageAccess(), TYPO3\CMS\Backend\History\RecordHistory\hasTableAccess(), and TYPO3\CMS\Backend\History\RecordHistory\resolveElement().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryData().

◆ getHistoryEntry()

array TYPO3\CMS\Backend\History\RecordHistory::getHistoryEntry ( int  $lastHistoryEntry)
protected

Resolve tablename + record uid from sys_history UID

Parameters
int$lastHistoryEntry
Returns
‪array

Definition at line 392 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, and TYPO3\CMS\Backend\History\RecordHistory\getQueryBuilder().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\updateCurrentElement().

◆ getLastHistoryEntryNumber()

TYPO3\CMS\Backend\History\RecordHistory::getLastHistoryEntryNumber ( )

◆ getQueryBuilder()

◆ hasPageAccess()

bool TYPO3\CMS\Backend\History\RecordHistory::hasPageAccess (   $table,
  $uid 
)
protected

◆ hasTableAccess()

bool TYPO3\CMS\Backend\History\RecordHistory::hasTableAccess (   $table)
protected

Determines whether user has access to a table.

Parameters
string$table
Returns
‪bool

Definition at line 569 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getBackendUser().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord().

◆ legacyUpdates()

TYPO3\CMS\Backend\History\RecordHistory::legacyUpdates ( )

@TODO: In v11 remove this function, this only exists for legacy reasons

Definition at line 599 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\getChangeLog().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\performRollback().

◆ performRollback()

TYPO3\CMS\Backend\History\RecordHistory::performRollback ( )

◆ prepareEventDataFromQueryBuilder()

◆ resolveElement()

int TYPO3\CMS\Backend\History\RecordHistory::resolveElement ( string  $table,
int  $uid 
)
protected

Convert input element reference to workspace version if any.

Parameters
string$table‪Table of input element
int$uid‪UID of record
Returns
‪int converted UID of record

Definition at line 377 of file RecordHistory.php.

References $GLOBALS, TYPO3\CMS\Backend\History\RecordHistory\getBackendUser(), and TYPO3\CMS\Backend\Utility\BackendUtility\getWorkspaceVersionOfRecord().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getHistoryDataForRecord().

◆ sanitizeElementValue()

string TYPO3\CMS\Backend\History\RecordHistory::sanitizeElementValue (   $value)
protected

Sanitizes the values for the expected disposal. Invalid values will be converted to an empty string.

Parameters
string$value‪the value of the element value
Returns
‪string

Definition at line 541 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\__construct().

◆ sanitizeRollbackFieldsValue()

string TYPO3\CMS\Backend\History\RecordHistory::sanitizeRollbackFieldsValue (   $value)
protected

Evaluates if the rollback field is correct

Parameters
string$value
Returns
‪string

Definition at line 555 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\__construct().

◆ setLastHistoryEntry()

TYPO3\CMS\Backend\History\RecordHistory::setLastHistoryEntry ( int  $lastHistoryEntryNumber)

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

Parameters
int$lastHistoryEntryNumber
Deprecated:
‪since TYPO3 v10.1, will be removed in TYPO3 v11.0, use setLastHistoryEntryNumber() instead.

Definition at line 105 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\setLastHistoryEntryNumber().

◆ setLastHistoryEntryNumber()

TYPO3\CMS\Backend\History\RecordHistory::setLastHistoryEntryNumber ( int  $lastHistoryEntry)

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

Parameters
int$lastHistoryEntry

Definition at line 115 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$lastHistoryEntry, and TYPO3\CMS\Backend\History\RecordHistory\updateCurrentElement().

Referenced by TYPO3\CMS\Backend\History\RecordHistory\setLastHistoryEntry().

◆ setMaxSteps()

TYPO3\CMS\Backend\History\RecordHistory::setMaxSteps ( int  $maxSteps)

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

Parameters
int$maxSteps

Definition at line 132 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$maxSteps.

◆ setShowSubElements()

TYPO3\CMS\Backend\History\RecordHistory::setShowSubElements ( bool  $showSubElements)

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

Parameters
bool$showSubElements

Definition at line 143 of file RecordHistory.php.

References TYPO3\CMS\Backend\History\RecordHistory\$showSubElements.

◆ shouldPerformRollback()

bool TYPO3\CMS\Backend\History\RecordHistory::shouldPerformRollback ( )

Whether rollback mode is on

Returns
‪bool
Deprecated:
‪since TYPO3 v10.1, will be removed in TYPO3 v11.0.

Definition at line 176 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\performRollback().

◆ updateCurrentElement()

TYPO3\CMS\Backend\History\RecordHistory::updateCurrentElement ( )
protected

Member Data Documentation

◆ $changeLog

array TYPO3\CMS\Backend\History\RecordHistory::$changeLog = array( )
protected

Definition at line 75 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getDiff().

◆ $deprecatedPublicMethods

string [] TYPO3\CMS\Backend\History\RecordHistory::$deprecatedPublicMethods
private
Initial value:
= array(
'getHistoryEntry' => 'Using RecordHistory::getHistoryEntry() is deprecated and will not be possible anymore in TYPO3 v11.0.',
'getHistoryData' => 'Using RecordHistory::getHistoryData() is deprecated and will not be possible anymore in TYPO3 v11.0.',
)

Definition at line 37 of file RecordHistory.php.

◆ $deprecatedPublicProperties

string [] TYPO3\CMS\Backend\History\RecordHistory::$deprecatedPublicProperties
private
Initial value:
= array(
'changeLog' => 'Using changeLog is deprecated and will not be possible anymore in TYPO3 v11.0. Use getChangeLog() instead.',
'lastHistoryEntry' => 'Using lastHistoryEntry is deprecated and will not be possible anymore in TYPO3 v11.0. Use getLastHistoryEntryNumber() instead.',
)

Definition at line 44 of file RecordHistory.php.

◆ $element

string TYPO3\CMS\Backend\History\RecordHistory::$element
protected

Element reference, syntax [tablename]:[uid]

Definition at line 65 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\getElementString().

◆ $lastHistoryEntry

◆ $maxSteps

int TYPO3\CMS\Backend\History\RecordHistory::$maxSteps = 20
protected

Maximum number of sys_history steps to show.

Definition at line 53 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\setMaxSteps().

◆ $pageAccessCache

array TYPO3\CMS\Backend\History\RecordHistory::$pageAccessCache = array( )
protected

Internal cache

Definition at line 80 of file RecordHistory.php.

◆ $rollbackFields

string TYPO3\CMS\Backend\History\RecordHistory::$rollbackFields = ''
protected

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

Definition at line 85 of file RecordHistory.php.

◆ $showSubElements

bool TYPO3\CMS\Backend\History\RecordHistory::$showSubElements = true
protected

On a pages table - show sub elements as well.

Definition at line 59 of file RecordHistory.php.

Referenced by TYPO3\CMS\Backend\History\RecordHistory\setShowSubElements().