‪TYPO3CMS  9.5
TYPO3\CMS\Core\Database\ReferenceIndex Class Reference
Inheritance diagram for TYPO3\CMS\Core\Database\ReferenceIndex:

Public Member Functions

 __construct ()
 
 setWorkspaceId ($workspaceId)
 
int getWorkspaceId ()
 
array updateRefIndexTable ($tableName, $uid, $testOnly=false)
 
array null generateRefIndexData ($tableName, $uid)
 
int getNumberOfReferencedRecords (string $tableName, int $uid)
 
array null createEntryData ($table, $uid, $field, $flexPointer, $deleted, $ref_table, $ref_uid, $ref_string='', $sort=-1, $softref_key='', $softref_id='')
 
 createEntryData_dbRels ($table, $uid, $fieldName, $flexPointer, $deleted, $items)
 
 createEntryData_fileRels ($table, $uid, $fieldName, $flexPointer, $deleted, $items)
 
 createEntryData_softreferences ($table, $uid, $fieldName, $flexPointer, $deleted, $keys)
 
array getRelations ($table, $row, $onlyField='')
 
 getRelations_flexFormCallBack ($dsArr, $dataValue, $PA, $structurePath)
 
bool array getRelations_procFiles ($value, $conf, $uid)
 
array bool getRelations_procDB ($value, $conf, $uid, $table='')
 
string bool array setReferenceValue ($hash, $newValue, $returnDataArray=false, $bypassWorkspaceAdminCheck=false)
 
string setReferenceValue_dbRels ($refRec, $itemArray, $newValue, &$dataArray, $flexPointer='')
 
string setReferenceValue_fileRels ($refRec, $itemArray, $newValue, &$dataArray, $flexPointer='')
 
string setReferenceValue_softreferences ($refRec, $softref, $newValue, &$dataArray, $flexPointer='')
 
bool isReferenceField (array $configuration)
 
string destPathFromUploadFolder ($folder)
 
array updateIndex ($testOnly, $cli_echo=false)
 
 enableRuntimeCache ()
 
 disableRuntimeCache ()
 

Public Attributes

array $temp_flexRelations = array( )
 
bool $WSOL = false
 
array $relations = array( )
 
int $hashVersion = 1
 

Protected Member Functions

array generateDataUsingRecord (string $tableName, array $record)
 
array bool createEntryDataUsingRecord (string $tableName, array $record, string $fieldName, string $flexPointer, int $deleted, string $referencedTable, int $referencedUid, string $referenceString='', int $sort=-1, string $softReferenceKey='', string $softReferenceId='')
 
 createEntryDataForDatabaseRelationsUsingRecord (string $tableName, array $record, string $fieldName, string $flexPointer, int $deleted, array $items)
 
 createEntryDataForFileRelationsUsingRecord (string $tableName, array $record, string $fieldName, string $flexPointer, int $deleted, array $items)
 
 createEntryDataForSoftReferencesUsingRecord (string $tableName, array $record, string $fieldName, string $flexPointer, int $deleted, array $keys)
 
bool isDbReferenceField (array $configuration)
 
string fetchTableRelationFields ($tableName)
 
array false getRecordRawCached (string $tableName, int $uid)
 
bool shouldExcludeTableFromReferenceIndex ($tableName)
 
bool shouldExcludeTableColumnFromReferenceIndex ($tableName, $column, $onlyColumn)
 
TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser ()
 

Protected Attributes

array $recordCache = array( )
 
int $workspaceId = 0
 
TYPO3 CMS Core Cache Frontend FrontendInterface $runtimeCache
 
bool $useRuntimeCache = false
 

Static Protected Attributes

static array $excludedTables
 
static array $excludedColumns
 
static string $cachePrefixTableRelationFields = 'core-refidx-tblRelFields-'
 

Detailed Description

Reference index processing and relation extraction

NOTICE: When the reference index is updated for an offline version the results may not be correct. First, lets assumed that the reference update happens in LIVE workspace (ALWAYS update from Live workspace if you analyze whole database!) Secondly, lets assume that in a Draft workspace you have changed the data structure of a parent page record - this is (in TemplaVoila) inherited by subpages. When in the LIVE workspace the data structure for the records/pages in the offline workspace will not be evaluated to the right one simply because the data structure is taken from a rootline traversal and in the Live workspace that will NOT include the changed DataStructure! Thus the evaluation will be based on the Data Structure set in the Live workspace! Somehow this scenario is rarely going to happen. Yet, it is an inconsistency and I see now practical way to handle it - other than simply ignoring maintaining the index for workspace records. Or we can say that the index is precise for all Live elements while glitches might happen in an offline workspace? Anyway, I just wanted to document this finding - I don't think we can find a solution for it. And its very TemplaVoila specific.

Definition at line 49 of file ReferenceIndex.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Database\ReferenceIndex::__construct ( )

Constructor

Definition at line 153 of file ReferenceIndex.php.

Member Function Documentation

◆ createEntryData()

array null TYPO3\CMS\Core\Database\ReferenceIndex::createEntryData (   $table,
  $uid,
  $field,
  $flexPointer,
  $deleted,
  $ref_table,
  $ref_uid,
  $ref_string = '',
  $sort = -1,
  $softref_key = '',
  $softref_id = '' 
)

Create array with field/value pairs ready to insert in database. The "hash" field is a fingerprint value across this table.

Parameters
string$table‪Tablename of source record (where reference is located)
int$uid‪UID of source record (where reference is located)
string$field‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in [field]
int$deleted‪Whether record is deleted-flagged or not
string$ref_table‪For database references; the tablename the reference points to. Special keyword "_FILE" indicates that "ref_string" is a file reference either absolute or relative to Environment::getPublicPath(). Special keyword "_STRING" indicates some special usage (typ. softreference) where "ref_string" is used for the value.
int$ref_uid‪For database references; The UID of the record (zero "ref_table" is "_FILE" or "_STRING")
string$ref_string‪For "_FILE" or "_STRING" references: The filepath (relative to Environment::getPublicPath() or absolute) or other string.
int$sort‪The sorting order of references if many (the "group" or "select" TCA types). -1 if no sorting order is specified.
string$softref_key‪If the reference is a soft reference, this is the soft reference parser key. Otherwise empty.
string$softref_id‪Soft reference ID for key. Might be useful for replace operations.
Returns
‪array|null Array record to insert into table.

Definition at line 443 of file ReferenceIndex.php.

◆ createEntryData_dbRels()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryData_dbRels (   $table,
  $uid,
  $fieldName,
  $flexPointer,
  $deleted,
  $items 
)

Enter database references to ->relations array

Parameters
string$table‪Tablename of source record (where reference is located)
int$uid‪UID of source record (where reference is located)
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in [field]
int$deleted‪Whether record is deleted-flagged or not
array$items‪Data array with database relations (table/id)

Definition at line 516 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForDatabaseRelationsUsingRecord(), and TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached().

◆ createEntryData_fileRels()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryData_fileRels (   $table,
  $uid,
  $fieldName,
  $flexPointer,
  $deleted,
  $items 
)

Enter file references to ->relations array

Parameters
string$table‪Tablename of source record (where reference is located)
int$uid‪UID of source record (where reference is located)
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in [field]
int$deleted‪Whether record is deleted-flagged or not
array$items‪Data array with file relations

Definition at line 559 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForFileRelationsUsingRecord(), and TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached().

◆ createEntryData_softreferences()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryData_softreferences (   $table,
  $uid,
  $fieldName,
  $flexPointer,
  $deleted,
  $keys 
)

Enter softref references to ->relations array

Parameters
string$table‪Tablename of source record (where reference is located)
int$uid‪UID of source record (where reference is located)
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure
int$deleted
array$keys‪Data array with soft reference keys

Definition at line 616 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForSoftReferencesUsingRecord(), and TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached().

◆ createEntryDataForDatabaseRelationsUsingRecord()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryDataForDatabaseRelationsUsingRecord ( string  $tableName,
array  $record,
string  $fieldName,
string  $flexPointer,
int  $deleted,
array  $items 
)
protected

Add database references to ->relations array based on fetched record

Parameters
string$tableName‪Tablename of source record (where reference is located)
array$record‪Record from $tableName
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in $fieldName
int$deleted‪Whether record is deleted-flagged or not
array$items‪Data array with database relations (table/id)

Definition at line 542 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataUsingRecord().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_dbRels().

◆ createEntryDataForFileRelationsUsingRecord()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryDataForFileRelationsUsingRecord ( string  $tableName,
array  $record,
string  $fieldName,
string  $flexPointer,
int  $deleted,
array  $items 
)
protected

Add file references to ->relations array based on fetched record

Parameters
string$tableName‪Tablename of source record (where reference is located)
array$record‪Record from $tableName
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in $fieldName
int$deleted‪Whether record is deleted-flagged or not
array$items‪Data array with file relations

Definition at line 585 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataUsingRecord(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), and TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_fileRels().

◆ createEntryDataForSoftReferencesUsingRecord()

TYPO3\CMS\Core\Database\ReferenceIndex::createEntryDataForSoftReferencesUsingRecord ( string  $tableName,
array  $record,
string  $fieldName,
string  $flexPointer,
int  $deleted,
array  $keys 
)
protected

Add SoftReference references to ->relations array based on fetched record

Parameters
string$tableName‪Tablename of source record (where reference is located)
array$record‪Record from $tableName
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in $fieldName
int$deleted‪Whether record is deleted-flagged or not
array$keys‪Data array with soft reference keys

Definition at line 642 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataUsingRecord().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_softreferences().

◆ createEntryDataUsingRecord()

array bool TYPO3\CMS\Core\Database\ReferenceIndex::createEntryDataUsingRecord ( string  $tableName,
array  $record,
string  $fieldName,
string  $flexPointer,
int  $deleted,
string  $referencedTable,
int  $referencedUid,
string  $referenceString = '',
int  $sort = -1,
string  $softReferenceKey = '',
string  $softReferenceId = '' 
)
protected

Create array with field/value pairs ready to insert in database

Parameters
string$tableName‪Tablename of source record (where reference is located)
array$record‪Record from $table
string$fieldName‪Fieldname of source record (where reference is located)
string$flexPointer‪Pointer to location inside FlexForm structure where reference is located in [$field]
int$deleted‪Whether record is deleted-flagged or not
string$referencedTable‪In database references the tablename the reference points to. Keyword "_FILE" indicates that $referenceString is a file reference, keyword "_STRING" indicates special usage (typ. SoftReference) in $referenceString
int$referencedUid‪In database references the UID of the record (zero $referencedTable is "_FILE" or "_STRING")
string$referenceString‪For "_FILE" or "_STRING" references: The filepath (relative to Environment::getPublicPath() or absolute) or other string.
int$sort‪The sorting order of references if many (the "group" or "select" TCA types). -1 if no sorting order is specified.
string$softReferenceKey‪If the reference is a soft reference, this is the soft reference parser key. Otherwise empty.
string$softReferenceId‪Soft reference ID for key. Might be useful for replace operations.
Returns
‪array|bool Array to insert in DB or false if record should not be processed

Definition at line 480 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForDatabaseRelationsUsingRecord(), TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForFileRelationsUsingRecord(), and TYPO3\CMS\Core\Database\ReferenceIndex\createEntryDataForSoftReferencesUsingRecord().

◆ destPathFromUploadFolder()

string TYPO3\CMS\Core\Database\ReferenceIndex::destPathFromUploadFolder (   $folder)

Returns destination path to an upload folder given by $folder

Parameters
string$folder‪Folder relative to TYPO3's public folder ("site path")
Returns
‪string Input folder prefixed with Environment::getPublicPath(). No checking for existence is done. Output must be a folder without trailing slash.

Definition at line 1310 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Core\Environment\getPublicPath().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procFiles().

◆ disableRuntimeCache()

TYPO3\CMS\Core\Database\ReferenceIndex::disableRuntimeCache ( )

Disables the runtime-based cache

Definition at line 1627 of file ReferenceIndex.php.

◆ enableRuntimeCache()

TYPO3\CMS\Core\Database\ReferenceIndex::enableRuntimeCache ( )

Enables the runtime-based caches Could lead to side effects, depending if the reference index instance is run multiple times while records would be changed.

Definition at line 1619 of file ReferenceIndex.php.

◆ fetchTableRelationFields()

string TYPO3\CMS\Core\Database\ReferenceIndex::fetchTableRelationFields (   $tableName)
protected

Returns all fields of a table which could contain a relation

Parameters
string$tableName‪Name of the table
Returns
‪string Fields which could contain a relation

Definition at line 1278 of file ReferenceIndex.php.

References $fields, $GLOBALS, and TYPO3\CMS\Core\Database\ReferenceIndex\isReferenceField().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached(), and TYPO3\CMS\Core\Database\ReferenceIndex\updateRefIndexTable().

◆ generateDataUsingRecord()

array TYPO3\CMS\Core\Database\ReferenceIndex::generateDataUsingRecord ( string  $tableName,
array  $record 
)
protected

Calculate the relations for a record of a given table

Parameters
string$tableName‪Table being processed
array$record‪Record from $tableName
Returns
‪array

Definition at line 372 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\updateRefIndexTable().

◆ generateRefIndexData()

array null TYPO3\CMS\Core\Database\ReferenceIndex::generateRefIndexData (   $tableName,
  $uid 
)

Returns array of arrays with an index of all references found in record from table/uid If the result is used to update the sys_refindex table then ->WSOL must NOT be TRUE (no workspace overlay anywhere!)

Parameters
string$tableName‪Table name from $GLOBALS['TCA']
int$uid‪Record UID
Returns
‪array|null Index Rows

Definition at line 315 of file ReferenceIndex.php.

◆ getBackendUser()

TYPO3 CMS Core Authentication BackendUserAuthentication TYPO3\CMS\Core\Database\ReferenceIndex::getBackendUser ( )
protected

Returns the current BE user.

Returns
‪\TYPO3\CMS\Core\Authentication\BackendUserAuthentication

Definition at line 1637 of file ReferenceIndex.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue().

◆ getNumberOfReferencedRecords()

int TYPO3\CMS\Core\Database\ReferenceIndex::getNumberOfReferencedRecords ( string  $tableName,
int  $uid 
)

Returns the amount of references for the given record

Parameters
string$tableName
int$uid
Returns
‪int

Definition at line 344 of file ReferenceIndex.php.

◆ getRecordRawCached()

array false TYPO3\CMS\Core\Database\ReferenceIndex::getRecordRawCached ( string  $tableName,
int  $uid 
)
protected

Gets one record from database and stores it in an internal cache (which expires along with object lifecycle) for faster retrieval

Assumption:

  • ‪This method is only used from within delegate methods and so only caches queries generated based on the record being indexed; the query to select origin side record is uncached
  • ‪Origin side records do not change in database while updating the reference index
  • ‪Origin record does not get removed while updating index
  • ‪Relations may change during indexing, which is why only the origin record is cached and all relations are re-process even when repeating indexing of the same origin record

Please note that the cache is disabled by default but can be enabled using $this->enableRuntimeCaches() due to possible side-effects while handling references that were changed during one single request.

Parameters
string$tableName
int$uid
Returns
‪array|false

Definition at line 1514 of file ReferenceIndex.php.

References $GLOBALS, TYPO3\CMS\Core\Database\ReferenceIndex\$relations, TYPO3\CMS\Core\Database\ReferenceIndex\fetchTableRelationFields(), and TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_dbRels(), TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_fileRels(), TYPO3\CMS\Core\Database\ReferenceIndex\createEntryData_softreferences(), and TYPO3\CMS\Core\Database\ReferenceIndex\updateRefIndexTable().

◆ getRelations()

array TYPO3\CMS\Core\Database\ReferenceIndex::getRelations (   $table,
  $row,
  $onlyField = '' 
)

Returns relation information for a $table/$row-array Traverses all fields in input row which are configured in TCA/columns It looks for hard relations to files and records in the TCA types "select" and "group"

Parameters
string$table‪Table name
array$row‪Row from table
string$onlyField‪Specific field to fetch for.
Returns
‪array Array with information about relations
See also
‪export_addRecord()

Definition at line 685 of file ReferenceIndex.php.

References $GLOBALS, TYPO3\CMS\Core\Database\ReferenceIndex\$temp_flexRelations, TYPO3\CMS\Backend\Utility\BackendUtility\explodeSoftRefParserList(), TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procDB(), TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procFiles(), TYPO3\CMS\Core\Database\ReferenceIndex\shouldExcludeTableColumnFromReferenceIndex(), and TYPO3\CMS\Backend\Utility\BackendUtility\softRefParserObj().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue().

◆ getRelations_flexFormCallBack()

TYPO3\CMS\Core\Database\ReferenceIndex::getRelations_flexFormCallBack (   $dsArr,
  $dataValue,
  $PA,
  $structurePath 
)

Callback function for traversing the FlexForm structure in relation to finding file and DB references!

Parameters
array$dsArr‪Data structure for the current value
mixed$dataValue‪Current value
array$PA‪Additional configuration used in calling function
string$structurePath‪Path of value in DS structure
See also
DataHandler::checkValue_flex_procInData_travDS(),FlexFormTools::traverseFlexFormXMLData()

Definition at line 795 of file ReferenceIndex.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\explodeSoftRefParserList(), TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procDB(), TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procFiles(), and TYPO3\CMS\Backend\Utility\BackendUtility\softRefParserObj().

◆ getRelations_procDB()

array bool TYPO3\CMS\Core\Database\ReferenceIndex::getRelations_procDB (   $value,
  $conf,
  $uid,
  $table = '' 
)

Check field configuration if it is a DB relation field and extract DB relations if any

Parameters
string$value‪Field value
array$conf‪Field configuration array of type "TCA/columns
int$uid‪Field uid
string$table‪Table name
Returns
‪array|bool If field type is OK it will return an array with the database relations. Else FALSE

Definition at line 933 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\isDbReferenceField().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations(), and TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_flexFormCallBack().

◆ getRelations_procFiles()

bool array TYPO3\CMS\Core\Database\ReferenceIndex::getRelations_procFiles (   $value,
  $conf,
  $uid 
)

Check field configuration if it is a file relation field and extract file relations if any

Parameters
string$value‪Field value
array$conf‪Field configuration array of type "TCA/columns
int$uid‪Field uid
Returns
‪bool|array If field type is OK it will return an array with the files inside. Else FALSE
Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. Deprecation logged by TcaMigration class.

Definition at line 872 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Database\ReferenceIndex\destPathFromUploadFolder(), TYPO3\CMS\Core\Resource\ResourceFactory\getInstance(), and TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations(), and TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_flexFormCallBack().

◆ getWorkspaceId()

int TYPO3\CMS\Core\Database\ReferenceIndex::getWorkspaceId ( )

Gets the current workspace id

Returns
‪int
See also
updateRefIndexTable(),createEntryData()

Definition at line 175 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\$workspaceId.

◆ isDbReferenceField()

bool TYPO3\CMS\Core\Database\ReferenceIndex::isDbReferenceField ( array  $configuration)
protected

Returns TRUE if the TCA/columns field type is a DB reference field

Parameters
array$configuration‪Config array for TCA/columns field
Returns
‪bool TRUE if DB reference field (group/db or select with foreign-table)

Definition at line 1240 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations_procDB(), and TYPO3\CMS\Core\Database\ReferenceIndex\isReferenceField().

◆ isReferenceField()

bool TYPO3\CMS\Core\Database\ReferenceIndex::isReferenceField ( array  $configuration)

Returns TRUE if the TCA/columns field type is a reference field

Parameters
array$configuration‪Config array for TCA/columns field
Returns
‪bool TRUE if reference field

Definition at line 1257 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\isDbReferenceField().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\fetchTableRelationFields().

◆ setReferenceValue()

string bool array TYPO3\CMS\Core\Database\ReferenceIndex::setReferenceValue (   $hash,
  $newValue,
  $returnDataArray = false,
  $bypassWorkspaceAdminCheck = false 
)

Setting the value of a reference or removing it completely. Usage: For lowlevel clean up operations! WARNING: With this you can set values that are not allowed in the database since it will bypass all checks for validity! Hence it is targeted at clean-up operations. Please use DataHandler in the usual ways if you wish to manipulate references. Since this interface allows updates to soft reference values (which DataHandler does not directly) you may like to use it for that as an exception to the warning above. Notice; If you want to remove multiple references from the same field, you MUST start with the one having the highest sorting number. If you don't the removal of a reference with a lower number will recreate an index in which the remaining references in that field has new hash-keys due to new sorting numbers - and you will get errors for the remaining operations which cannot find the hash you feed it! To ensure proper working only admin-BE_USERS in live workspace should use this function

Parameters
string$hash‪32-byte hash string identifying the record from sys_refindex which you wish to change the value for
mixed$newValue‪Value you wish to set for reference. If NULL, the reference is removed (unless a soft-reference in which case it can only be set to a blank string). If you wish to set a database reference, use the format "[table]:[uid]". Any other case, the input value is set as-is
bool$returnDataArray‪Return $dataArray only, do not submit it to database.
bool$bypassWorkspaceAdminCheck‪If set, it will bypass check for workspace-zero and admin user
Returns
‪string|bool|array FALSE (=OK), error message string or array (if $returnDataArray is set!)

Definition at line 983 of file ReferenceIndex.php.

References $GLOBALS, TYPO3\CMS\Core\Database\ReferenceIndex\getBackendUser(), TYPO3\CMS\Core\Database\ReferenceIndex\getRelations(), TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue_dbRels(), TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue_fileRels(), and TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue_softreferences().

◆ setReferenceValue_dbRels()

string TYPO3\CMS\Core\Database\ReferenceIndex::setReferenceValue_dbRels (   $refRec,
  $itemArray,
  $newValue,
$dataArray,
  $flexPointer = '' 
)

Setting a value for a reference for a DB field:

Parameters
array$refRec‪sys_refindex record
array$itemArray‪Array of references from that field
string$newValue‪Value to substitute current value with (or NULL to unset it)
array$dataArray‪Data array in which the new value is set (passed by reference)
string$flexPointer‪Flexform pointer, if in a flex form field.
Returns
‪string Error message if any, otherwise FALSE = OK

Definition at line 1117 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue().

◆ setReferenceValue_fileRels()

string TYPO3\CMS\Core\Database\ReferenceIndex::setReferenceValue_fileRels (   $refRec,
  $itemArray,
  $newValue,
$dataArray,
  $flexPointer = '' 
)

Setting a value for a reference for a FILE field:

Parameters
array$refRec‪sys_refindex record
array$itemArray‪Array of references from that field
string$newValue‪Value to substitute current value with (or NULL to unset it)
array$dataArray‪Data array in which the new value is set (passed by reference)
string$flexPointer‪Flexform pointer, if in a flex form field.
Returns
‪string Error message if any, otherwise FALSE = OK

Definition at line 1157 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix().

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue().

◆ setReferenceValue_softreferences()

string TYPO3\CMS\Core\Database\ReferenceIndex::setReferenceValue_softreferences (   $refRec,
  $softref,
  $newValue,
$dataArray,
  $flexPointer = '' 
)

Setting a value for a soft reference token

Parameters
array$refRec‪sys_refindex record
array$softref‪Array of soft reference occurencies
string$newValue‪Value to substitute current value with
array$dataArray‪Data array in which the new value is set (passed by reference)
string$flexPointer‪Flexform pointer, if in a flex form field.
Returns
‪string Error message if any, otherwise FALSE = OK

Definition at line 1198 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\setReferenceValue().

◆ setWorkspaceId()

TYPO3\CMS\Core\Database\ReferenceIndex::setWorkspaceId (   $workspaceId)

Sets the current workspace id

Parameters
int$workspaceId
See also
updateIndex()

Definition at line 164 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\$workspaceId.

◆ shouldExcludeTableColumnFromReferenceIndex()

bool TYPO3\CMS\Core\Database\ReferenceIndex::shouldExcludeTableColumnFromReferenceIndex (   $tableName,
  $column,
  $onlyColumn 
)
protected

Checks if a given column in a given table should be excluded in the ReferenceIndex process

Parameters
string$tableName‪Name of the table
string$column‪Name of the column
string$onlyColumn‪Name of a specific column to fetch
Returns
‪bool true if it should be excluded

Definition at line 1601 of file ReferenceIndex.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations().

◆ shouldExcludeTableFromReferenceIndex()

bool TYPO3\CMS\Core\Database\ReferenceIndex::shouldExcludeTableFromReferenceIndex (   $tableName)
protected

Checks if a given table should be excluded from ReferenceIndex

Parameters
string$tableName‪Name of the table
Returns
‪bool true if it should be excluded

Definition at line 1576 of file ReferenceIndex.php.

References $signalSlotDispatcher.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\updateIndex(), and TYPO3\CMS\Core\Database\ReferenceIndex\updateRefIndexTable().

◆ updateIndex()

array TYPO3\CMS\Core\Database\ReferenceIndex::updateIndex (   $testOnly,
  $cli_echo = false 
)

Updating Index (External API)

Parameters
bool$testOnly‪If set, only a test
bool$cli_echo‪If set, output CLI status
Returns
‪array Header and body status content

Definition at line 1322 of file ReferenceIndex.php.

References $errors, $fields, $GLOBALS, TYPO3\CMS\Core\Database\ConnectionPool\DEFAULT_CONNECTION_NAME, TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR, TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), TYPO3\CMS\Core\Messaging\AbstractMessage\OK, and TYPO3\CMS\Core\Database\ReferenceIndex\shouldExcludeTableFromReferenceIndex().

◆ updateRefIndexTable()

array TYPO3\CMS\Core\Database\ReferenceIndex::updateRefIndexTable (   $tableName,
  $uid,
  $testOnly = false 
)

Call this function to update the sys_refindex table for a record (even one just deleted) NOTICE: Currently, references updated for a deleted-flagged record will not include those from within FlexForm fields in some cases where the data structure is defined by another record since the resolving process ignores deleted records! This will also result in bad cleaning up in DataHandler I think... Anyway, that's the story of FlexForms; as long as the DS can change, lots of references can get lost in no time.

Parameters
string$tableName‪Table name
int$uid‪UID of record
bool$testOnly‪If set, nothing will be written to the index but the result value will still report statistics on what is added, deleted and kept. Can be used for mere analysis.
Returns
‪array Array with statistics about how many index records were added, deleted and not altered plus the complete reference set for the record.

Definition at line 192 of file ReferenceIndex.php.

References TYPO3\CMS\Core\Database\ReferenceIndex\$relations, TYPO3\CMS\Core\Database\ReferenceIndex\fetchTableRelationFields(), TYPO3\CMS\Core\Database\ReferenceIndex\generateDataUsingRecord(), TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached(), and TYPO3\CMS\Core\Database\ReferenceIndex\shouldExcludeTableFromReferenceIndex().

Member Data Documentation

◆ $cachePrefixTableRelationFields

string TYPO3\CMS\Core\Database\ReferenceIndex::$cachePrefixTableRelationFields = 'core-refidx-tblRelFields-'
staticprotected

Fields of tables that could contain relations are cached per table. This is the prefix for the cache entries since the runtimeCache has a global scope.

Definition at line 95 of file ReferenceIndex.php.

◆ $excludedColumns

array TYPO3\CMS\Core\Database\ReferenceIndex::$excludedColumns
staticprotected
Initial value:
= array(
'uid' => true,
'perms_userid' => true,
'perms_groupid' => true,
'perms_user' => true,
'perms_group' => true,
'perms_everybody' => true,
'pid' => true
)

Definition of fields to exclude from ReferenceIndex in every table

Implemented as array with fields as keys and booleans as values for fast isset() lookup instead of slow in_array()

See also
getRelations()
fetchTableRelationFields()
shouldExcludeTableColumnFromReferenceIndex()

Definition at line 80 of file ReferenceIndex.php.

◆ $excludedTables

array TYPO3\CMS\Core\Database\ReferenceIndex::$excludedTables
staticprotected
Initial value:
= array(
'sys_log' => true,
'sys_history' => true,
'tx_extensionmanager_domain_model_extension' => true
)

Definition of tables to exclude from the ReferenceIndex

Only tables which do not contain any relations and never did so far since references also won't be deleted for these. Since only tables with an entry in $GLOBALS['TCA] are handled by ReferenceIndex there is no need to add *_mm-tables.

Implemented as array with fields as keys and booleans as values for fast isset() lookup instead of slow in_array()

See also
updateRefIndexTable()
shouldExcludeTableFromReferenceIndex()

Definition at line 65 of file ReferenceIndex.php.

◆ $hashVersion

int TYPO3\CMS\Core\Database\ReferenceIndex::$hashVersion = 1

Number which we can increase if a change in the code means we will have to force a re-generation of the index.

See also
updateRefIndexTable()

Definition at line 131 of file ReferenceIndex.php.

◆ $recordCache

array TYPO3\CMS\Core\Database\ReferenceIndex::$recordCache = array( )
protected

A cache to avoid that identical rows are refetched from the database

See also
getRecordRawCached()

Definition at line 124 of file ReferenceIndex.php.

◆ $relations

array TYPO3\CMS\Core\Database\ReferenceIndex::$relations = array( )

An index of all found references of a single record created in createEntryData() and accumulated in generateRefIndexData()

See also
createEntryData(),generateRefIndexData()

Definition at line 117 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRecordRawCached(), and TYPO3\CMS\Core\Database\ReferenceIndex\updateRefIndexTable().

◆ $runtimeCache

TYPO3 CMS Core Cache Frontend FrontendInterface TYPO3\CMS\Core\Database\ReferenceIndex::$runtimeCache
protected

Runtime Cache to store and retrieve data computed for a single request

Definition at line 143 of file ReferenceIndex.php.

◆ $temp_flexRelations

array TYPO3\CMS\Core\Database\ReferenceIndex::$temp_flexRelations = array( )

This array holds the FlexForm references of a record

See also
getRelations(),FlexFormTools::traverseFlexFormXMLData(),getRelations_flexFormCallBack()

Definition at line 102 of file ReferenceIndex.php.

Referenced by TYPO3\CMS\Core\Database\ReferenceIndex\getRelations().

◆ $useRuntimeCache

bool TYPO3\CMS\Core\Database\ReferenceIndex::$useRuntimeCache = false
protected

Enables $runtimeCache and $recordCache

Definition at line 148 of file ReferenceIndex.php.

◆ $workspaceId

int TYPO3\CMS\Core\Database\ReferenceIndex::$workspaceId = 0
protected

◆ $WSOL

bool TYPO3\CMS\Core\Database\ReferenceIndex::$WSOL = false

This variable used to indicate whether referencing should take workspace overlays into account It is not used since commit 0c34dac08605ba from 10.04.2006, the bug is investigated in https://forge.typo3.org/issues/65725

See also
getRelations()

Definition at line 110 of file ReferenceIndex.php.