34 parent::__construct();
36 $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.');
37 $this->cli_options[] = array(
'--pid id',
'Setting start page in page tree. Default is the page tree root, 0 (zero)');
38 $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.');
39 $this->cli_options[] = array(
'--flush-live',
'If set, not only published versions from Live workspace are flushed, but ALL versions from Live workspace (which are offline of course)');
40 $this->
cli_help[
'name'] =
'versions -- To find information about versions and workspaces in the system';
41 $this->
cli_help[
'description'] = trim(
' 42 Traversing page tree and finding versions, categorizing them by various properties. 43 Published versions from the Live workspace are registered. So are all offline versions from Live workspace in general. Further, versions in non-existing workspaces are found. 46 - Deleting (completely) published versions from LIVE workspace OR _all_ offline versions from Live workspace (toogle by --flush-live) 47 - Resetting workspace for versions where workspace is deleted. (You might want to run this tool again after this operation to clean out those new elements in the Live workspace) 48 - Deleting unused placeholders 64 'message' => $this->
cli_help[
'name'] . LF . LF . $this->
cli_help[
'description'],
66 'versions' => array(
'All versions',
'Showing all versions of records found', 0),
67 'versions_published' => array(
'All published versions',
'This is all records that has been published and can therefore be removed permanently', 1),
68 'versions_liveWS' => array(
'All versions in Live workspace',
'This is all records that are offline versions in the Live workspace. You may wish to flush these if you only use workspaces for versioning since then you might find lots of versions piling up in the live workspace which have simply been disconnected from the workspace before they were published.', 1),
69 'versions_lost_workspace' => array(
'Versions outside a workspace',
'Versions that has lost their connection to a workspace in TYPO3.', 3),
70 'versions_inside_versioned_page' => array(
'Versions in versions',
'Versions inside an already versioned page. Something that is confusing to users and therefore should not happen but is technically possible.', 2),
71 'versions_unused_placeholders' => array(
'Unused placeholder records',
'Placeholder records which are not used anymore by offline versions.', 2),
72 'versions_move_placeholders_ok' => array(
'Move placeholders',
'Move-to placeholder records which has good integrity', 0),
73 'versions_move_placeholders_bad' => array(
'Move placeholders with bad integrity',
'Move-to placeholder records which has bad integrity', 2),
74 'versions_move_id_check' => array(
'Checking if t3ver_move_id is correct',
't3ver_move_id must only be set with online records having t3ver_state=3.', 2)
81 $resultArray[
'versions'] = $this->recStats[
'versions'];
82 $resultArray[
'versions_published'] = $this->recStats[
'versions_published'];
83 $resultArray[
'versions_liveWS'] = $this->recStats[
'versions_liveWS'];
84 $resultArray[
'versions_lost_workspace'] = $this->recStats[
'versions_lost_workspace'];
85 $resultArray[
'versions_inside_versioned_page'] = $this->recStats[
'versions_inside_versioned_page'];
87 $resultArray[
'versions_unused_placeholders'] = array();
88 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
89 if ($cfg[
'ctrl'][
'versioningWS']) {
90 $placeHolders =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
95 foreach ($placeHolders as $phrec) {
97 $resultArray[
'versions_unused_placeholders'][GeneralUtility::shortmd5($table .
':' . $phrec[
'uid'])] = $table .
':' . $phrec[
'uid'];
102 asort($resultArray[
'versions_unused_placeholders']);
104 $resultArray[
'versions_move_placeholders_ok'] = array();
105 $resultArray[
'versions_move_placeholders_bad'] = array();
106 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
107 if ((
int)$cfg[
'ctrl'][
'versioningWS'] >= 2) {
108 $placeHolders =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
109 'uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state',
113 foreach ($placeHolders as $phrec) {
114 $shortID = GeneralUtility::shortmd5($table .
':' . $phrec[
'uid']);
115 if ((
int)$phrec[
't3ver_wsid'] != 0) {
120 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'State for version was not "4" as it should be!', $phrecCopy);
122 $resultArray[
'versions_move_placeholders_ok'][$shortID] = array(
123 $table .
':' . $phrec[
'uid'],
130 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'No version was found for online record to be moved. A version must exist.', $phrecCopy);
133 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'Did not find online record for "t3ver_move_id" value ' . $phrec[
't3ver_move_id'], $phrec);
136 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'Placeholder was not assigned a workspace value in t3ver_wsid.', $phrec);
141 ksort($resultArray[
'versions_move_placeholders_ok']);
142 ksort($resultArray[
'versions_move_placeholders_bad']);
144 $resultArray[
'versions_move_id_check'] = array();
145 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
146 if ((
int)$cfg[
'ctrl'][
'versioningWS'] >= 2) {
148 foreach ($placeHolders as $phrec) {
150 if ($phrec[
'pid'] != -1) {
153 $resultArray[
'versions_move_id_check'][] = array($table .
':' . $phrec[
'uid'],
'Record was offline, must not be!', $phrec);
156 $resultArray[
'versions_move_id_check'][] = array($table .
':' . $phrec[
'uid'],
'Record had t3ver_move_id set to "' . $phrec[
't3ver_move_id'] .
'" while having t3ver_state=' . $phrec[
't3ver_state'], $phrec);
173 $kk = $this->
cli_isArg(
'--flush-live') ?
'versions_liveWS' :
'versions_published';
175 if (isset($resultArray[$kk][
'pages'])) {
176 $_pages = $resultArray[$kk][
'pages'];
177 unset($resultArray[$kk][
'pages']);
178 $resultArray[$kk][
'pages'] = $_pages;
181 foreach ($resultArray[$kk] as $table => $list) {
182 echo
'Flushing published records from table "' . $table .
'":' . LF;
183 foreach ($list as
$uid) {
184 echo
' Flushing record "' . $table .
':' . $uid .
'": ';
190 $tce->stripslashes_values = FALSE;
191 $tce->start(array(), array());
192 $tce->deleteEl($table, $uid, TRUE, TRUE);
194 if (count($tce->errorLog)) {
195 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);
204 foreach ($resultArray[
'versions_lost_workspace'] as $table => $list) {
205 echo
'Resetting workspace to zero for records from table "' . $table .
'":' . LF;
206 foreach ($list as
$uid) {
207 echo
' Flushing record "' . $table .
':' . $uid .
'": ';
211 $fields_values = array(
214 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $fields_values);
221 foreach ($resultArray[
'versions_unused_placeholders'] as $recID) {
222 list($table,
$uid) = explode(
':', $recID);
223 echo
'Deleting unused placeholder (soft) "' . $table .
':' .
$uid .
'": ';
229 $tce->stripslashes_values = FALSE;
230 $tce->start(array(), array());
231 $tce->deleteAction($table, $uid);
233 if (count($tce->errorLog)) {
234 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);
static getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields=' *')
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static movePlhOL($table, &$row)
static makeInstance($className)
cli_argValue($option, $idx=0)
main_autoFix($resultArray)
cli_noExecutionCheck($matchString)
static selectVersionsOfRecord($table, $uid, $fields=' *', $workspace=0, $includeDeletedRecords=FALSE, $row=NULL)
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'][]
static deleteClause($table, $tableAlias='')