30 parent::__construct();
32 $this->cli_options[] = array(
'--echotree level',
'When "level" is set to 1 or higher you will see the page of the page tree outputted as it is traversed. A value of 2 for "level" will show even more information.');
33 $this->
cli_help[
'name'] =
'orphan_records -- To find records that has lost their connection with the page tree';
34 $this->
cli_help[
'description'] = trim(
' 36 - That all actively used records on the website from TCA configured tables are located in the page tree exclusively. 38 All records managed by TYPO3 via the TCA array configuration has to belong to a page in the page tree, either directly or indirectly as a version of another record. 39 VERY TIME, CPU and MEMORY intensive operation since the full page tree is looked up! 41 Automatic Repair of Errors: 42 - Silently deleting the orphaned records. In theory they should not be used anywhere in the system, but there could be references. See below for more details on this matter. 44 Manual repair suggestions: 45 - Possibly re-connect orphaned records to page tree by setting their "pid" field to a valid page id. A lookup in the sys_refindex table can reveal if there are references to a orphaned record. If there are such references (from records that are not themselves orphans) you might consider to re-connect the record to the page tree, otherwise it should be safe to delete it. 48 - Implement a check for references to orphaned records and if a reference comes from a record that is not orphaned itself, we might rather like to re-connect the record to the page tree. 49 - Implement that orphans can be fixed by setting the PID to a certain page instead of deleting.');
50 $this->
cli_help[
'examples'] =
'/.../cli_dispatch.phpsh lowlevel_cleaner orphan_records -s -r 51 Will report orphan uids from TCA tables.';
65 'message' => $this->
cli_help[
'name'] . LF . LF . $this->
cli_help[
'description'],
67 'orphans' => array(
'Index of orphaned records',
'', 3),
68 'misplaced_at_rootlevel' => array(
'Records that should not be at root level but are.',
'Fix manually by moving record into page tree', 2),
69 'misplaced_inside_tree' => array(
'Records that should be at root level but are not.',
'Fix manually by moving record to tree root', 2),
70 'illegal_record_under_versioned_page' => array(
'Records that cannot be attached to a versioned page',
'(Listed under orphaned records so is fixed along with orphans.)', 2)
73 'misplaced_at_rootlevel' => array(),
75 'misplaced_inside_tree' => array(),
77 'illegal_record_under_versioned_page' => array()
83 $resultArray[
'misplaced_at_rootlevel'] = $this->recStats[
'misplaced_at_rootlevel'];
84 $resultArray[
'misplaced_inside_tree'] = $this->recStats[
'misplaced_inside_tree'];
85 $resultArray[
'illegal_record_under_versioned_page'] = $this->recStats[
'illegal_record_under_versioned_page'];
87 foreach (
$GLOBALS[
'TCA'] as $tableName => $cfg) {
88 $idList = is_array($this->recStats[
'all'][$tableName]) && count($this->recStats[
'all'][$tableName]) ? implode(
',', $this->recStats[
'all'][$tableName]) : 0;
90 $orphanRecords =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid', $tableName,
'uid NOT IN (' . $idList .
')',
'',
'uid',
'',
'uid');
91 if (count($orphanRecords)) {
92 $resultArray[
'orphans'][$tableName] = array();
93 foreach ($orphanRecords as $oR) {
94 $resultArray[
'orphans'][$tableName][$oR[
'uid']] = $oR[
'uid'];
111 if (isset($resultArray[
'orphans'][
'pages'])) {
112 $_pages = $resultArray[
'orphans'][
'pages'];
113 unset($resultArray[
'orphans'][
'pages']);
114 $resultArray[
'orphans'][
'pages'] = $_pages;
117 foreach ($resultArray[
'orphans'] as $table => $list) {
118 echo
'Removing orphans from table "' . $table .
'":' . LF;
119 foreach ($list as
$uid) {
120 echo
' Flushing orphan record "' . $table .
':' . $uid .
'": ';
126 $tce->stripslashes_values = FALSE;
127 $tce->start(array(), array());
130 $tce->deleteRecord($table, $uid, TRUE, TRUE);
132 if (count($tce->errorLog)) {
133 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);
main_autoFix($resultArray)
static makeInstance($className)
cli_argValue($option, $idx=0)
cli_noExecutionCheck($matchString)
genTree($rootID, $depth=1000, $echoLevel=0, $callBack='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]