2 namespace TYPO3\CMS\Lowlevel;
31 parent::__construct();
33 $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.');
34 $this->cli_options[] = array(
'--pid id',
'Setting start page in page tree. Default is the page tree root, 0 (zero)');
35 $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.');
36 $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)');
37 $this->
cli_help[
'name'] =
'versions -- To find information about versions and workspaces in the system';
38 $this->
cli_help[
'description'] = trim(
'
39 Traversing page tree and finding versions, categorizing them by various properties.
40 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.
43 - Deleting (completely) published versions from LIVE workspace OR _all_ offline versions from Live workspace (toogle by --flush-live)
44 - 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)
45 - Deleting unused placeholders
60 'message' => $this->
cli_help[
'name'] . LF . LF . $this->
cli_help[
'description'],
62 'versions' => array(
'All versions',
'Showing all versions of records found', 0),
63 'versions_published' => array(
'All published versions',
'This is all records that has been published and can therefore be removed permanently', 1),
64 '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),
65 'versions_lost_workspace' => array(
'Versions outside a workspace',
'Versions that has lost their connection to a workspace in TYPO3.', 3),
66 '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),
67 'versions_unused_placeholders' => array(
'Unused placeholder records',
'Placeholder records which are not used anymore by offline versions.', 2),
68 'versions_move_placeholders_ok' => array(
'Move placeholders',
'Move-to placeholder records which has good integrity', 0),
69 'versions_move_placeholders_bad' => array(
'Move placeholders with bad integrity',
'Move-to placeholder records which has bad integrity', 2),
70 '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)
74 $startingPoint = $this->
cli_isArg(
'--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->
cli_argValue(
'--pid'), 0) : 0;
75 $depth = $this->
cli_isArg(
'--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->
cli_argValue(
'--depth'), 0) : 1000;
77 $resultArray[
'versions'] = $this->recStats[
'versions'];
78 $resultArray[
'versions_published'] = $this->recStats[
'versions_published'];
79 $resultArray[
'versions_liveWS'] = $this->recStats[
'versions_liveWS'];
80 $resultArray[
'versions_lost_workspace'] = $this->recStats[
'versions_lost_workspace'];
81 $resultArray[
'versions_inside_versioned_page'] = $this->recStats[
'versions_inside_versioned_page'];
83 $resultArray[
'versions_unused_placeholders'] = array();
84 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
85 if ($cfg[
'ctrl'][
'versioningWS']) {
86 $placeHolders =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
91 foreach ($placeHolders as $phrec) {
93 $resultArray[
'versions_unused_placeholders'][GeneralUtility::shortmd5($table .
':' . $phrec[
'uid'])] = $table .
':' . $phrec[
'uid'];
98 asort($resultArray[
'versions_unused_placeholders']);
100 $resultArray[
'versions_move_placeholders_ok'] = array();
101 $resultArray[
'versions_move_placeholders_bad'] = array();
102 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
104 $placeHolders =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
105 'uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state',
109 foreach ($placeHolders as $phrec) {
110 $shortID = GeneralUtility::shortmd5($table .
':' . $phrec[
'uid']);
111 if ((
int)$phrec[
't3ver_wsid'] != 0) {
116 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'State for version was not "4" as it should be!', $phrecCopy);
118 $resultArray[
'versions_move_placeholders_ok'][$shortID] = array(
119 $table .
':' . $phrec[
'uid'],
126 $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);
129 $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);
132 $resultArray[
'versions_move_placeholders_bad'][$shortID] = array($table .
':' . $phrec[
'uid'],
'Placeholder was not assigned a workspace value in t3ver_wsid.', $phrec);
137 ksort($resultArray[
'versions_move_placeholders_ok']);
138 ksort($resultArray[
'versions_move_placeholders_bad']);
140 $resultArray[
'versions_move_id_check'] = array();
141 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
144 foreach ($placeHolders as $phrec) {
146 if ($phrec[
'pid'] != -1) {
148 $resultArray[
'versions_move_id_check'][] = array($table .
':' . $phrec[
'uid'],
'Record was offline, must not be!', $phrec);
151 $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);
168 $kk = $this->
cli_isArg(
'--flush-live') ?
'versions_liveWS' :
'versions_published';
170 if (isset($resultArray[$kk][
'pages'])) {
171 $_pages = $resultArray[$kk][
'pages'];
172 unset($resultArray[$kk][
'pages']);
173 $resultArray[$kk][
'pages'] = $_pages;
176 foreach ($resultArray[$kk] as $table =>
$list) {
177 echo
'Flushing published records from table "' . $table .
'":' . LF;
178 foreach (
$list as $uid) {
179 echo
' Flushing record "' . $table .
':' . $uid .
'": ';
185 $tce->stripslashes_values =
false;
186 $tce->start(array(), array());
187 $tce->deleteEl($table, $uid,
true,
true);
189 if (count($tce->errorLog)) {
190 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);
199 foreach ($resultArray[
'versions_lost_workspace'] as $table =>
$list) {
200 echo
'Resetting workspace to zero for records from table "' . $table .
'":' . LF;
201 foreach (
$list as $uid) {
202 echo
' Flushing record "' . $table .
':' . $uid .
'": ';
206 $fields_values = array(
209 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $fields_values);
216 foreach ($resultArray[
'versions_unused_placeholders'] as $recID) {
217 list($table, $uid) = explode(
':', $recID);
218 echo
'Deleting unused placeholder (soft) "' . $table .
':' . $uid .
'": ';
224 $tce->stripslashes_values =
false;
225 $tce->start(array(), array());
226 $tce->deleteAction($table, $uid);
228 if (count($tce->errorLog)) {
229 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);