‪TYPO3CMS  9.5
TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck Class Reference

Public Member Functions

 __construct ()
 
array getPageTranslatedPageIDArray ()
 
 genTree ($theID, $depthData='', $versions=false)
 
 genTree_records ($theID, $_='', $table='', $versions=false)
 
 lostRecords ($pid_list)
 
bool fixLostRecord ($table, $uid)
 
array countRecords ($pid_list)
 
array getGroupFields ($mode)
 
array getFileFields ($uploadfolder)
 
array getDBFields ($theSearchTable)
 
 selectNonEmptyRecordsWithFkeys ($fkey_arrays)
 
array testFileRefs ()
 
string testDBRefs ($theArray)
 
array whereIsRecordReferenced ($searchTable, $id)
 
array whereIsFileReferenced ($uploadFolder, $filename)
 

Public Attributes

bool $genTree_includeDeleted = true
 
 $genTree_includeVersions = true
 
bool $genTree_includeRecords = false
 
 $page_idArray = array( )
 
array $rec_idArray = array( )
 
array $checkFileRefs = array( )
 
array $checkSelectDBRefs = array( )
 
array $checkGroupDBRefs = array( )
 
array $recStats
 
array $lRecords = array( )
 
string $lostPagesList = ''
 

Protected Attributes

 $page_translatedPageIDArray = array( )
 

Detailed Description

This class holds functions used by the TYPO3 backend to check the integrity of the database (The DBint module, 'lowlevel' extension)

Depends on \TYPO3\CMS\Core\Database\RelationHandler

Todo:
‪Need to really extend this class when the DataHandler library has been updated and the whole API is better defined. There are some known bugs in this library. Further it would be nice with a facility to not only analyze but also clean up!
See also
‪\TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController::func_relations(), \TYPO3\CMS\Lowlevel\Controller\DatabaseIntegrityController::func_records()

Definition at line 36 of file DatabaseIntegrityCheck.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::__construct ( )

DatabaseIntegrityCheck constructor.

Definition at line 96 of file DatabaseIntegrityCheck.php.

Member Function Documentation

◆ countRecords()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::countRecords (   $pid_list)

Counts records from $GLOBALS['TCA']-tables that ARE attached to an existing page.

Parameters
string$pid_list‪list of pid's (page-record uid's). This list is probably made by genTree()
Returns
‪array an array with the number of records from all $GLOBALS['TCA']-tables that are attached to a PID in the pid-list.

Definition at line 307 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled().

◆ fixLostRecord()

bool TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::fixLostRecord (   $table,
  $uid 
)

Fixes lost record from $table with uid $uid by setting the PID to zero. If there is a disabled column for the record that will be set as well.

Parameters
string$tableDatabase tablename
int$uid‪The uid of the record which will have the PID value set to 0 (zero)
Returns
‪bool TRUE if done.

Definition at line 283 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

◆ genTree()

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::genTree (   $theID,
  $depthData = '',
  $versions = false 
)

Generates a list of Page-uid's that corresponds to the tables in the tree. This list should ideally include all records in the pages-table.

Parameters
int$theID‪a pid (page-record id) from which to start making the tree
string$depthData‪HTML-code (image-tags) used when this function calls itself recursively.
bool$versions‪Internal variable, don't set from outside!

Definition at line 117 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\genTree_records().

◆ genTree_records()

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::genTree_records (   $theID,
  $_ = '',
  $table = '',
  $versions = false 
)
Parameters
int$theID‪a pid (page-record id) from which to start making the tree
string$_‪Unused parameter
string$table‪Table to get the records from
bool$versions‪Internal variable, don't set from outside!

Definition at line 185 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and TYPO3\CMS\Backend\Utility\BackendUtility\getCommonSelectFields().

Referenced by TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\genTree().

◆ getDBFields()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::getDBFields (   $theSearchTable)

Returns an array with arrays of table/field pairs which are allowed to hold references to the input table name - according to $GLOBALS['TCA']

Parameters
string$theSearchTable‪Table name
Returns
‪array

Definition at line 415 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\whereIsRecordReferenced().

◆ getFileFields()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::getFileFields (   $uploadfolder)

Finds all fields that hold filenames from uploadfolder

Parameters
string$uploadfolder‪Path to uploadfolder
Returns
‪array An array with all fields listed that have references to files in the $uploadfolder
Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. Deprecation logged by TcaMigration class.

Definition at line 395 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\whereIsFileReferenced().

◆ getGroupFields()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::getGroupFields (   $mode)

Finding relations in database based on type 'group' (files or database-uid's in a list)

Parameters
string$mode‪$mode = file, $mode = db, $mode = '' (all...)
Returns
‪array An array with all fields listed that somehow are references to other records (foreign-keys) or files

Definition at line 365 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

◆ getPageTranslatedPageIDArray()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::getPageTranslatedPageIDArray ( )

◆ lostRecords()

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::lostRecords (   $pid_list)

Fills $this->lRecords with the records from all tc-tables that are not attached to a PID in the pid-list.

Parameters
string$pid_list‪list of pid's (page-record uid's). This list is probably made by genTree()

Definition at line 232 of file DatabaseIntegrityCheck.php.

References $GLOBALS, TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle(), and TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled().

◆ selectNonEmptyRecordsWithFkeys()

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::selectNonEmptyRecordsWithFkeys (   $fkey_arrays)

This selects non-empty-records from the tables/fields in the fkey_array generated by getGroupFields()

Parameters
array$fkey_arrays‪Array with tables/fields generated by getGroupFields()
See also
getGroupFields()

Definition at line 439 of file DatabaseIntegrityCheck.php.

References $fields, $GLOBALS, and TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\GT.

◆ testDBRefs()

string TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::testDBRefs (   $theArray)

Depends on selectNonEmpty.... to be executed first!!

Parameters
array$theArray‪Table with key/value pairs being table names and arrays with uid numbers
Returns
‪string HTML Error message

Definition at line 655 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

◆ testFileRefs()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::testFileRefs ( )

Depends on selectNonEmpty.... to be executed first!!

Returns
‪array Report over files; keys are "moreReferences", "noReferences", "noFile", "error

Definition at line 577 of file DatabaseIntegrityCheck.php.

References $GLOBALS, $output, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Utility\PathUtility\dirname(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), and TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\whereIsFileReferenced().

◆ whereIsFileReferenced()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::whereIsFileReferenced (   $uploadFolder,
  $filename 
)

Finding all references to file based on uploadfolder / filename

Parameters
string$uploadFolder‪Upload folder where file is found
string$filename‪Filename to search for
Returns
‪array Array with other arrays containing information about where references was found

Definition at line 751 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\getFileFields().

Referenced by TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\testFileRefs().

◆ whereIsRecordReferenced()

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::whereIsRecordReferenced (   $searchTable,
  $id 
)

Finding all references to record based on table/uid

Parameters
string$searchTable‪Table name
int$id‪Uid of database record
Returns
‪array Array with other arrays containing information about where references was found

Definition at line 702 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck\getDBFields().

Member Data Documentation

◆ $checkFileRefs

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$checkFileRefs = array( )

Definition at line 67 of file DatabaseIntegrityCheck.php.

◆ $checkGroupDBRefs

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$checkGroupDBRefs = array( )

From the group-fields

Definition at line 75 of file DatabaseIntegrityCheck.php.

◆ $checkSelectDBRefs

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$checkSelectDBRefs = array( )

From the select-fields

Definition at line 71 of file DatabaseIntegrityCheck.php.

◆ $genTree_includeDeleted

bool TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$genTree_includeDeleted = true

If set, genTree() includes deleted pages. This is default.

Definition at line 40 of file DatabaseIntegrityCheck.php.

◆ $genTree_includeRecords

bool TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$genTree_includeRecords = false

If set, genTree() includes records from pages.

Definition at line 49 of file DatabaseIntegrityCheck.php.

◆ $genTree_includeVersions

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$genTree_includeVersions = true

Definition at line 45 of file DatabaseIntegrityCheck.php.

◆ $lostPagesList

string TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$lostPagesList = ''

Definition at line 91 of file DatabaseIntegrityCheck.php.

◆ $lRecords

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$lRecords = array( )

Definition at line 87 of file DatabaseIntegrityCheck.php.

◆ $page_idArray

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$page_idArray = array( )

Definition at line 54 of file DatabaseIntegrityCheck.php.

◆ $page_translatedPageIDArray

TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$page_translatedPageIDArray = array( )
protected

◆ $rec_idArray

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$rec_idArray = array( )

Definition at line 63 of file DatabaseIntegrityCheck.php.

◆ $recStats

array TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck::$recStats
Initial value:
= array(
'allValid' => [],
'published_versions' => [],
'deleted' => []
)

Statistics

Definition at line 79 of file DatabaseIntegrityCheck.php.