TYPO3  7.6
Public Member Functions | Public Attributes | List of all members
DatabaseIntegrityCheck Class Reference

Public Member Functions

 genTree ($theID, $depthData= '', $versions=false)
 
 genTree_records ($theID, $_= '', $table= '', $versions=false)
 
 lostRecords ($pid_list)
 
 fixLostRecord ($table, $uid)
 
 countRecords ($pid_list)
 
 getGroupFields ($mode)
 
 getFileFields ($uploadfolder)
 
 getDBFields ($theSearchTable)
 
 testFileRefs ()
 
 testDBRefs ($theArray)
 
 whereIsFileReferenced ($uploadfolder, $filename)
 

Public Attributes

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

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: Depends on

Todo:
Need to really extend this class when the tcemain 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
::func_relations(), ::func_records()

Definition at line 27 of file DatabaseIntegrityCheck.php.

Member Function Documentation

countRecords (   $pid_list)

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

Parameters
string$pid_listlist 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 258 of file DatabaseIntegrityCheck.php.

References $GLOBALS, $list, and BackendUtility\deleteClause().

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$uidThe uid of the record which will have the PID value set to 0 (zero)
Returns
bool TRUE if done.

Definition at line 236 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

array Will hold id rec pairs from 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$theIDa pid (page-record id) from which to start making the tree
string$depthDataHTML-code (image-tags) used when this function calls itself recursively.
bool$versionsInternal variable, don't set from outside!
Returns
void

Definition at line 102 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and DatabaseIntegrityCheck\genTree_records().

genTree_records (   $theID,
  $_ = '',
  $table = '',
  $versions = false 
)
Parameters
int$theIDa pid (page-record id) from which to start making the tree
string$_Unused parameter
string$tableTable to get the records from
bool$versionsInternal variable, don't set from outside!
Returns
void

Definition at line 155 of file DatabaseIntegrityCheck.php.

References $GLOBALS, BackendUtility\deleteClause(), and BackendUtility\getCommonSelectFields().

Referenced by DatabaseIntegrityCheck\genTree().

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$theSearchTableTable name
Returns
array

Definition at line 336 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and elseif.

getFileFields (   $uploadfolder)

Finds all fields that hold filenames from uploadfolder

Parameters
string$uploadfolderPath to uploadfolder
Returns
array An array with all fields listed that have references to files in the $uploadfolder

Definition at line 316 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

Referenced by DatabaseIntegrityCheck\whereIsFileReferenced().

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 288 of file DatabaseIntegrityCheck.php.

References $GLOBALS.

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_listlist of pid's (page-record uid's). This list is probably made by genTree()
Returns
void

Definition at line 200 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and BackendUtility\getRecordTitle().

testDBRefs (   $theArray)

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

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

Definition at line 517 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and BackendUtility\deleteClause().

testFileRefs ( )

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

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

Definition at line 439 of file DatabaseIntegrityCheck.php.

References $GLOBALS, and DatabaseIntegrityCheck\whereIsFileReferenced().

whereIsFileReferenced (   $uploadfolder,
  $filename 
)

Finding all references to file based on uploadfolder / filename

Parameters
string$uploadfolderUpload folder where file is found
string$filenameFilename to search for
Returns
array Array with other arrays containing information about where references was found

Definition at line 586 of file DatabaseIntegrityCheck.php.

References $filename, $GLOBALS, and DatabaseIntegrityCheck\getFileFields().

Referenced by DatabaseIntegrityCheck\testFileRefs().

Member Data Documentation

$checkFileRefs = array()

Definition at line 62 of file DatabaseIntegrityCheck.php.

$checkGroupDBRefs = array()

Definition at line 72 of file DatabaseIntegrityCheck.php.

$checkSelectDBRefs = array()

Definition at line 67 of file DatabaseIntegrityCheck.php.

$genTree_includeDeleted = true

Definition at line 32 of file DatabaseIntegrityCheck.php.

$genTree_includeRecords = false

Definition at line 42 of file DatabaseIntegrityCheck.php.

$genTree_includeVersions = true

Definition at line 37 of file DatabaseIntegrityCheck.php.

$lostPagesList = ''

Definition at line 91 of file DatabaseIntegrityCheck.php.

$lRecords = array()

Definition at line 86 of file DatabaseIntegrityCheck.php.

$page_idArray = array()

Definition at line 52 of file DatabaseIntegrityCheck.php.

$perms_clause = ''

Definition at line 47 of file DatabaseIntegrityCheck.php.

$rec_idArray = array()

Definition at line 57 of file DatabaseIntegrityCheck.php.

$recStats
Initial value:
= array(
'allValid' => array(),
'published_versions' => array(),
'deleted' => array()
)

Definition at line 77 of file DatabaseIntegrityCheck.php.