2 namespace TYPO3\CMS\Lowlevel;
27 parent::__construct();
29 $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.');
30 $this->cli_options[] = array(
'--pid id',
'Setting start page in page tree. Default is the page tree root, 0 (zero)');
31 $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.');
32 $this->
cli_help[
'name'] =
'cleanflexform -- Find flexform fields with unclean XML';
33 $this->
cli_help[
'description'] = trim(
'
34 Traversing page tree and finding records with FlexForm fields with XML that could be cleaned up. This will just remove obsolete data garbage.
37 Cleaning XML for FlexForm fields.
52 'message' => $this->
cli_help[
'name'] . LF . LF . $this->
cli_help[
'description'],
54 'dirty' => array(
'',
'', 2)
58 $startingPoint = $this->
cli_isArg(
'--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->
cli_argValue(
'--pid'), 0) : 0;
59 $depth = $this->
cli_isArg(
'--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->
cli_argValue(
'--depth'), 0) : 1000;
60 $this->cleanFlexForm_dirtyFields = &$resultArray[
'dirty'];
62 $this->genTree_traverseDeleted =
false;
63 $this->
genTree($startingPoint, $depth, (
int)$this->
cli_argValue(
'--echotree'),
'main_parseTreeCallBack');
80 foreach (
$GLOBALS[
'TCA'][$tableName][
'columns'] as $colName => $config) {
81 if ($config[
'config'][
'type'] ==
'flex') {
83 echo LF .
' [cleanflexform:] Field "' . $colName .
'" in ' . $tableName .
':' . $uid .
' was a flexform and...';
85 $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($tableName,
'uid=' . (
int)$uid);
86 $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
87 if ($recRow[$colName]) {
89 $newXML = $flexObj->cleanFlexFormXML($tableName, $colName, $recRow);
90 if (md5($recRow[$colName]) != md5($newXML)) {
92 echo
' was DIRTY, needs cleanup!';
94 $this->cleanFlexForm_dirtyFields[\TYPO3\CMS\Core\Utility\GeneralUtility::shortMd5($tableName .
':' . $uid .
':' . $colName)] = $tableName .
':' . $uid .
':' . $colName;
100 }
elseif ($echoLevel > 2) {
116 foreach ($resultArray[
'dirty'] as $fieldID) {
117 list($table, $uid, $field) = explode(
':', $fieldID);
118 echo
'Cleaning XML in "' . $fieldID .
'": ';
124 $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($table,
'uid=' . (
int)$uid);
125 $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
126 if ($recRow[$field]) {
127 $data[$table][$uid][$field] = $flexObj->cleanFlexFormXML($table, $field, $recRow);
130 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
131 $tce->stripslashes_values =
false;
132 $tce->dontProcessTransformations =
true;
133 $tce->bypassWorkspaceRestrictions =
true;
134 $tce->bypassFileHandling =
true;
136 $tce->start($data, array());
137 $tce->process_datamap();
139 if (count($tce->errorLog)) {
140 echo
' ERROR from "TCEmain":' . LF .
'TCEmain:' . implode((LF .
'TCEmain:'), $tce->errorLog);