00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00056 class tx_lowlevel_deleted extends tx_lowlevel_cleaner_core {
00057
00063 function tx_lowlevel_deleted() {
00064 parent::tx_lowlevel_cleaner_core();
00065
00066
00067 $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.');
00068 $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
00069 $this->cli_options[] = array('--depth int', 'Setting traversal depth. 0 (zero) will only analyse start page (see --pid), 1 will traverse one level of subpages etc.');
00070
00071 $this->cli_help['name'] = 'deleted -- To find and flush deleted records in the page tree';
00072 $this->cli_help['description'] = trim('
00073 Traversing page tree and finding deleted records
00074
00075 Automatic Repair:
00076 Although deleted records are not errors to be repaired, this tool allows you to flush the deleted records completely from the system as an automatic action. Limiting this lookup by --pid and --depth can help you to narrow in the operation to a part of the page tree.
00077 ');
00078
00079 $this->cli_help['examples'] = '';
00080 }
00081
00088 function main() {
00089 global $TYPO3_DB;
00090
00091
00092 $resultArray = array(
00093 'message' => $this->cli_help['name'].chr(10).chr(10).$this->cli_help['description'],
00094 'headers' => array(
00095 'deleted' => array('Index of deleted records','These are records from the page tree having the deleted-flag set. The --AUTOFIX option will flush them completely!',1),
00096 ),
00097 'deleted' => array(),
00098 );
00099
00100 $startingPoint = $this->cli_isArg('--pid') ? t3lib_div::intInRange($this->cli_argValue('--pid'),0) : 0;
00101 $depth = $this->cli_isArg('--depth') ? t3lib_div::intInRange($this->cli_argValue('--depth'),0) : 1000;
00102 $this->genTree($startingPoint,$depth,(int)$this->cli_argValue('--echotree'));
00103
00104 $resultArray['deleted'] = $this->recStats['deleted'];
00105
00106 return $resultArray;
00107 }
00108
00116 function main_autoFix($resultArray) {
00117
00118
00119 if (isset($resultArray['deleted']['tx_templavoila_datastructure'])) {
00120 $_tx_templavoila_datastructure = $resultArray['deleted']['tx_templavoila_datastructure'];
00121 unset($resultArray['deleted']['tx_templavoila_datastructure']);
00122 $resultArray['deleted']['tx_templavoila_datastructure'] = $_tx_templavoila_datastructure;
00123 }
00124
00125
00126 if (isset($resultArray['deleted']['pages'])) {
00127 $_pages = $resultArray['deleted']['pages'];
00128 unset($resultArray['deleted']['pages']);
00129 $resultArray['deleted']['pages'] = array_reverse($_pages);
00130 }
00131
00132
00133 foreach($resultArray['deleted'] as $table => $list) {
00134 echo 'Flushing deleted records from table "'.$table.'":'.chr(10);
00135 foreach($list as $uid) {
00136 echo ' Flushing record "'.$table.':'.$uid.'": ';
00137 if ($bypass = $this->cli_noExecutionCheck($table.':'.$uid)) {
00138 echo $bypass;
00139 } else {
00140
00141
00142 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00143 $tce->stripslashes_values = FALSE;
00144 $tce->start(array(),array());
00145 $tce->deleteRecord($table,$uid, TRUE, TRUE);
00146
00147
00148 if (count($tce->errorLog)) {
00149 echo ' ERROR from "TCEmain":'.chr(10).'TCEmain:'.implode(chr(10).'TCEmain:',$tce->errorLog);
00150 } else echo "DONE";
00151 }
00152 echo chr(10);
00153 }
00154 }
00155 }
00156 }
00157
00158 ?>