[TASK] Merge ext:integrity with ext:lowlevel
authorMarkus Klein <klein.t3@mfc-linz.at>
Sat, 22 Sep 2012 22:22:36 +0000 (00:22 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 10 Oct 2012 19:00:55 +0000 (21:00 +0200)
System extension integrity was created with the namespace switch and
contains the cli classes from ext:lowlevel. It turns out that this
change was not so useful, so for now the cli classes are moved back
to ext:lowlevel.

Resolves: #40950
Releases: 6.0

Change-Id: I22020736e91d7d0079ecf47e9b7d30a758f98e4c
Reviewed-on: http://review.typo3.org/14954
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
55 files changed:
t3lib/class.t3lib_arraybrowser.php
typo3/sysext/core/Build/UnitTests.xml
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/integrity/Classes/AdminCommand.php [deleted file]
typo3/sysext/integrity/Classes/CleanFlexformCommand.php [deleted file]
typo3/sysext/integrity/Classes/CleanerCommand.php [deleted file]
typo3/sysext/integrity/Classes/DeletedRecordsCommand.php [deleted file]
typo3/sysext/integrity/Classes/DoubleFilesCommand.php [deleted file]
typo3/sysext/integrity/Classes/LostFilesCommand.php [deleted file]
typo3/sysext/integrity/Classes/MissingFilesCommand.php [deleted file]
typo3/sysext/integrity/Classes/MissingRelationsCommand.php [deleted file]
typo3/sysext/integrity/Classes/OrphanRecordsCommand.php [deleted file]
typo3/sysext/integrity/Classes/RteImagesCommand.php [deleted file]
typo3/sysext/integrity/Classes/SyslogCommand.php [deleted file]
typo3/sysext/integrity/Classes/Utility/ArrayBrowser.php [deleted file]
typo3/sysext/integrity/Classes/VersionsCommand.php [deleted file]
typo3/sysext/integrity/Classes/View/ConfigurationView.php [deleted file]
typo3/sysext/integrity/Classes/View/DatabaseIntegrityView.php [deleted file]
typo3/sysext/integrity/Migrations/Code/ClassAliasMap.php [deleted file]
typo3/sysext/integrity/Tests/Unit/Utility/ArrayBrowserTest.php [deleted file]
typo3/sysext/lowlevel/Classes/AdminCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/CleanFlexformCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/CleanerCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/DeletedRecordsCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/DoubleFilesCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/LostFilesCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/MissingFilesCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/MissingRelationsCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/OrphanRecordsCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/RteImagesCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/SyslogCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/Utility/ArrayBrowser.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/VersionsCommand.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/View/ConfigurationView.php [new file with mode: 0644]
typo3/sysext/lowlevel/Classes/View/DatabaseIntegrityView.php [new file with mode: 0644]
typo3/sysext/lowlevel/Migrations/Code/ClassAliasMap.php [new file with mode: 0644]
typo3/sysext/lowlevel/Tests/Unit/Utility/ArrayBrowserTest.php [new file with mode: 0644]
typo3/sysext/lowlevel/admin_cli.php
typo3/sysext/lowlevel/class.tx_lowlevel_admin_core.php
typo3/sysext/lowlevel/class.tx_lowlevel_cleaner_core.php
typo3/sysext/lowlevel/clmods/class.cleanflexform.php
typo3/sysext/lowlevel/clmods/class.deleted.php
typo3/sysext/lowlevel/clmods/class.double_files.php
typo3/sysext/lowlevel/clmods/class.lost_files.php
typo3/sysext/lowlevel/clmods/class.missing_files.php
typo3/sysext/lowlevel/clmods/class.missing_relations.php
typo3/sysext/lowlevel/clmods/class.orphan_records.php
typo3/sysext/lowlevel/clmods/class.rte_images.php
typo3/sysext/lowlevel/clmods/class.syslog.php
typo3/sysext/lowlevel/clmods/class.versions.php
typo3/sysext/lowlevel/config/index.php
typo3/sysext/lowlevel/dbint/cli/cleaner_cli.php
typo3/sysext/lowlevel/dbint/index.php
typo3/sysext/lowlevel/ext_localconf.php

index 480d4cc..ba9f2a9 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * @deprecated since 6.0, the classname t3lib_arrayBrowser and this file is obsolete
  * and will be removed by 7.0. The class was renamed and is now located at:
 /*
  * @deprecated since 6.0, the classname t3lib_arrayBrowser and this file is obsolete
  * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/integrity/Classes/Utility/ArrayBrowser.php
+ * typo3/sysext/lowlevel/Classes/Utility/ArrayBrowser.php
  */
  */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('integrity') . 'Classes/Utility/ArrayBrowser.php';
+require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('lowlevel') . 'Classes/Utility/ArrayBrowser.php';
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index b342e06..6bf6dee 100644 (file)
                <testsuite name="EXT:lang tests">
                        <directory>../../../../typo3/sysext/lang/Tests/Unit/</directory>
                </testsuite>
                <testsuite name="EXT:lang tests">
                        <directory>../../../../typo3/sysext/lang/Tests/Unit/</directory>
                </testsuite>
+               <testsuite name="EXT:lowlevel tests">
+                       <directory>../../../../typo3/sysext/lowlevel/Tests/Unit/</directory>
+               </testsuite>
                <testsuite name="EXT:saltedpasswords tests">
                        <directory>../../../../typo3/sysext/saltedpasswords/Tests/Unit/</directory>
                </testsuite>
                <testsuite name="EXT:scheduler tests">
                        <directory>../../../../typo3/sysext/scheduler/Tests/Unit/</directory>
                </testsuite>
                <testsuite name="EXT:saltedpasswords tests">
                        <directory>../../../../typo3/sysext/saltedpasswords/Tests/Unit/</directory>
                </testsuite>
                <testsuite name="EXT:scheduler tests">
                        <directory>../../../../typo3/sysext/scheduler/Tests/Unit/</directory>
                </testsuite>
-               <testsuite name="Suite integrity tests">
-                       <directory>../../../../typo3/sysext/core/Tests/Integrity/</directory>
-               </testsuite>
        </testsuites>
 
 </phpunit>
\ No newline at end of file
        </testsuites>
 
 </phpunit>
\ No newline at end of file
index f723793..81a81c8 100644 (file)
@@ -136,7 +136,7 @@ class SystemEnvironmentBuilder {
                // Security related constant: List of file extensions that should be registered as php script file extensions
                define('PHP_EXTENSIONS_DEFAULT', 'php,php3,php4,php5,php6,phpsh,inc,phtml');
                // List of extensions required to run the core
                // Security related constant: List of file extensions that should be registered as php script file extensions
                define('PHP_EXTENSIONS_DEFAULT', 'php,php3,php4,php5,php6,phpsh,inc,phtml');
                // List of extensions required to run the core
-               define('REQUIRED_EXTENSIONS', 'core,backend,frontend,cli,integrity,cms,lang,sv,extensionmanager,recordlist,extbase,fluid,cshmanual');
+               define('REQUIRED_EXTENSIONS', 'core,backend,frontend,cli,cms,lang,sv,extensionmanager,recordlist,extbase,fluid,cshmanual');
                // Operating system identifier
                // Either "WIN" or empty string
                define('TYPO3_OS', self::getTypo3Os());
                // Operating system identifier
                // Either "WIN" or empty string
                define('TYPO3_OS', self::getTypo3Os());
index 5f6277d..0625609 100644 (file)
@@ -5979,77 +5979,77 @@ class Tx_Install_Updates_File_TtContentUploadsUpdateWizard extends \TYPO3\CMS\In
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_admin_core extends \TYPO3\CMS\Integrity\AdminCommand {}
+class tx_lowlevel_admin_core extends \TYPO3\CMS\Lowlevel\AdminCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_cleaner_core extends \TYPO3\CMS\Integrity\CleanerCommand {}
+class tx_lowlevel_cleaner_core extends \TYPO3\CMS\Lowlevel\CleanerCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_cleanflexform extends \TYPO3\CMS\Integrity\CleanFlexformCommand {}
+class tx_lowlevel_cleanflexform extends \TYPO3\CMS\Lowlevel\CleanFlexformCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_deleted extends \TYPO3\CMS\Integrity\DeletedRecordsCommand {}
+class tx_lowlevel_deleted extends \TYPO3\CMS\Lowlevel\DeletedRecordsCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_double_files extends \TYPO3\CMS\Integrity\DoubleFilesCommand {}
+class tx_lowlevel_double_files extends \TYPO3\CMS\Lowlevel\DoubleFilesCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_lost_files extends \TYPO3\CMS\Integrity\LostFilesCommand {}
+class tx_lowlevel_lost_files extends \TYPO3\CMS\Lowlevel\LostFilesCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_missing_files extends \TYPO3\CMS\Integrity\MissingFilesCommand {}
+class tx_lowlevel_missing_files extends \TYPO3\CMS\Lowlevel\MissingFilesCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_missing_relations extends \TYPO3\CMS\Integrity\MissingRelationsCommand {}
+class tx_lowlevel_missing_relations extends \TYPO3\CMS\Lowlevel\MissingRelationsCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_orphan_records extends \TYPO3\CMS\Integrity\OrphanRecordsCommand {}
+class tx_lowlevel_orphan_records extends \TYPO3\CMS\Lowlevel\OrphanRecordsCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_rte_images extends \TYPO3\CMS\Integrity\RteImagesCommand {}
+class tx_lowlevel_rte_images extends \TYPO3\CMS\Lowlevel\RteImagesCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_syslog extends \TYPO3\CMS\Integrity\SyslogCommand {}
+class tx_lowlevel_syslog extends \TYPO3\CMS\Lowlevel\SyslogCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class t3lib_arrayBrowser extends \TYPO3\CMS\Integrity\Utility\ArrayBrowser {}
+class t3lib_arrayBrowser extends \TYPO3\CMS\Lowlevel\Utility\ArrayBrowser {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_lowlevel_versions extends \TYPO3\CMS\Integrity\VersionsCommand {}
+class tx_lowlevel_versions extends \TYPO3\CMS\Lowlevel\VersionsCommand {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class SC_mod_tools_config_index extends \TYPO3\CMS\Integrity\View\ConfigurationView {}
+class SC_mod_tools_config_index extends \TYPO3\CMS\Lowlevel\View\ConfigurationView {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class SC_mod_tools_dbint_index extends \TYPO3\CMS\Integrity\View\DatabaseIntegrityView {}
+class SC_mod_tools_dbint_index extends \TYPO3\CMS\Lowlevel\View\DatabaseIntegrityView {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
diff --git a/typo3/sysext/integrity/Classes/AdminCommand.php b/typo3/sysext/integrity/Classes/AdminCommand.php
deleted file mode 100644 (file)
index 52124da..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Core functions for admin
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Core functions for administration
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class AdminCommand extends \TYPO3\CMS\Core\Controller\CommandLineController {
-
-       /**
-        * @todo Define visibility
-        */
-       public $adminModules = array(
-               'setBElock' => 'Set the Backend Lock',
-               'clearBElock' => 'Clears the Backend Lock',
-               'msg' => 1
-       );
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               // Running parent class constructor
-               parent::__construct();
-               // Adding options to help archive:
-               $this->cli_options[] = array('--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.');
-               // Setting help texts:
-               $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line';
-               $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
-               $this->cli_help['description'] = 'The \'toolkey\' keywords are:
-
-  ' . implode('
-  ', array_keys($this->adminModules));
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/';
-               $this->cli_help['author'] = 'Kasper Skaarhoej, (c) 2009';
-       }
-
-       /**************************
-        *
-        * CLI functionality
-        *
-        *************************/
-       /**
-        * CLI engine
-        *
-        * @param array $argv Command line arguments
-        * @return string
-        * @todo Define visibility
-        */
-       public function cli_main($argv) {
-               // Force user to admin state and set workspace to "Live":
-               $GLOBALS['BE_USER']->user['admin'] = 1;
-               $GLOBALS['BE_USER']->setWorkspace(0);
-               // Print help
-               $analysisType = (string) $this->cli_args['_DEFAULT'][1];
-               if (!$analysisType) {
-                       $this->cli_validateArgs();
-                       $this->cli_help();
-                       die;
-               }
-               // Analysis type:
-               switch ((string) $analysisType) {
-               case 'setBElock':
-                       if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
-                               $this->cli_echo('A lockfile already exists. Overwriting it...
-');
-                       }
-                       $lockFileContent = $this->cli_argValue('--redirect');
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', $lockFileContent);
-                       $this->cli_echo('Wrote lock-file to \'' . PATH_typo3conf . 'LOCK_BACKEND\' with content \'' . $lockFileContent . '\'');
-                       break;
-               case 'clearBElock':
-                       if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
-                               unlink(PATH_typo3conf . 'LOCK_BACKEND');
-                               if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
-                                       $this->cli_echo('ERROR: Could not remove lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'!!
-', 1);
-                               } else {
-                                       $this->cli_echo('Removed lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'
-');
-                               }
-                       } else {
-                               $this->cli_echo('No lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\' was found; hence no lock can be removed.\'
-');
-                       }
-                       break;
-               default:
-                       $this->cli_echo('Unknown toolkey, \'' . $analysisType . '\'');
-                       break;
-               }
-               $this->cli_echo(LF);
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/CleanFlexformCommand.php b/typo3/sysext/integrity/Classes/CleanFlexformCommand.php
deleted file mode 100644 (file)
index b2ceb3b..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: cleanflexform
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * cleanflexform
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class CleanFlexformCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $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.');
-               $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
-               $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.');
-               $this->cli_help['name'] = 'cleanflexform -- Find flexform fields with unclean XML';
-               $this->cli_help['description'] = trim('
-Traversing page tree and finding records with FlexForm fields with XML that could be cleaned up. This will just remove obsolete data garbage.
-
-Automatic Repair:
-Cleaning XML for FlexForm fields.
-');
-               $this->cli_help['examples'] = '';
-       }
-
-       /**
-        * Find orphan records
-        * VERY CPU and memory intensive since it will look up the whole page tree!
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'dirty' => array('', '', 2)
-                       ),
-                       'dirty' => array()
-               );
-               $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
-               $depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
-               $this->cleanFlexForm_dirtyFields =& $resultArray['dirty'];
-               // Do not repair flexform data in deleted records.
-               $this->genTree_traverseDeleted = FALSE;
-               $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'), 'main_parseTreeCallBack');
-               asort($resultArray);
-               return $resultArray;
-       }
-
-       /**
-        * Call back function for page tree traversal!
-        *
-        * @param string $tableName Table name
-        * @param integer $uid UID of record in processing
-        * @param integer $echoLevel Echo level  (see calling function
-        * @param string $versionSwapmode Version swap mode on that level (see calling function
-        * @param integer $rootIsVersion Is root version (see calling function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_parseTreeCallBack($tableName, $uid, $echoLevel, $versionSwapmode, $rootIsVersion) {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName);
-               foreach ($GLOBALS['TCA'][$tableName]['columns'] as $colName => $config) {
-                       if ($config['config']['type'] == 'flex') {
-                               if ($echoLevel > 2) {
-                                       echo LF . '                     [cleanflexform:] Field "' . $colName . '" in ' . $tableName . ':' . $uid . ' was a flexform and...';
-                               }
-                               $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($tableName, 'uid=' . intval($uid));
-                               $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
-                               if ($recRow[$colName]) {
-                                       // Clean XML:
-                                       $newXML = $flexObj->cleanFlexFormXML($tableName, $colName, $recRow);
-                                       if (md5($recRow[$colName]) != md5($newXML)) {
-                                               if ($echoLevel > 2) {
-                                                       echo ' was DIRTY, needs cleanup!';
-                                               }
-                                               $this->cleanFlexForm_dirtyFields[\TYPO3\CMS\Core\Utility\GeneralUtility::shortMd5($tableName . ':' . $uid . ':' . $colName)] = $tableName . ':' . $uid . ':' . $colName;
-                                       } else {
-                                               if ($echoLevel > 2) {
-                                                       echo ' was CLEAN';
-                                               }
-                                       }
-                               } elseif ($echoLevel > 2) {
-                                       echo ' was EMPTY';
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               foreach ($resultArray['dirty'] as $fieldID) {
-                       list($table, $uid, $field) = explode(':', $fieldID);
-                       echo 'Cleaning XML in "' . $fieldID . '": ';
-                       if ($bypass = $this->cli_noExecutionCheck($fieldID)) {
-                               echo $bypass;
-                       } else {
-                               // Clean XML:
-                               $data = array();
-                               $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($table, 'uid=' . intval($uid));
-                               $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
-                               if ($recRow[$field]) {
-                                       $data[$table][$uid][$field] = $flexObj->cleanFlexFormXML($table, $field, $recRow);
-                               }
-                               // Execute Data array:
-                               $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
-                               $tce->stripslashes_values = FALSE;
-                               $tce->dontProcessTransformations = TRUE;
-                               $tce->bypassWorkspaceRestrictions = TRUE;
-                               $tce->bypassFileHandling = TRUE;
-                               // Check has been done previously that there is a backend user which is Admin and also in live workspace
-                               $tce->start($data, array());
-                               $tce->process_datamap();
-                               // Return errors if any:
-                               if (count($tce->errorLog)) {
-                                       echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
-                               } else {
-                                       echo 'DONE';
-                               }
-                       }
-                       echo LF;
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/CleanerCommand.php b/typo3/sysext/integrity/Classes/CleanerCommand.php
deleted file mode 100644 (file)
index 8cbf79f..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Core functions for cleaning and analysing
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Core functions for cleaning and analysing
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class CleanerCommand extends \TYPO3\CMS\Core\Controller\CommandLineController {
-
-       /**
-        * @todo Define visibility
-        */
-       public $genTree_traverseDeleted = TRUE;
-
-       /**
-        * @todo Define visibility
-        */
-       public $genTree_traverseVersions = TRUE;
-
-       /**
-        * @todo Define visibility
-        */
-       public $label_infoString = 'The list of records is organized as [table]:[uid]:[field]:[flexpointer]:[softref_key]';
-
-       /**
-        * @todo Define visibility
-        */
-       public $pagetreePlugins = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $cleanerModules = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $performanceStatistics = array();
-
-       protected $workspaceIndex = array();
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               // Running parent class constructor
-               parent::__construct();
-               $this->cleanerModules = (array) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lowlevel']['cleanerModules'];
-               // Adding options to help archive:
-               $this->cli_options[] = array('-r', 'Execute this tool, otherwise help is shown');
-               $this->cli_options[] = array('-v level', 'Verbosity level 0-3', 'The value of level can be:
-  0 = all output
-  1 = info and greater (default)
-  2 = warnings and greater
-  3 = errors');
-               $this->cli_options[] = array('--refindex mode', 'Mode for reference index handling for operations that require a clean reference index ("update"/"ignore")', 'Options are "check" (default), "update" and "ignore". By default, the reference index is checked before running analysis that require a clean index. If the check fails, the analysis is not run. You can choose to bypass this completely (using value "ignore") or ask to have the index updated right away before the analysis (using value "update")');
-               $this->cli_options[] = array('--AUTOFIX [testName]', 'Repairs errors that can be automatically fixed.', 'Only add this option after having run the test without it so you know what will happen when you add this option! The optional parameter "[testName]" works for some tool keys to limit the fixing to a particular test.');
-               $this->cli_options[] = array('--dryrun', 'With --AUTOFIX it will only simulate a repair process', 'You may like to use this to see what the --AUTOFIX option will be doing. It will output the whole process like if a fix really occurred but nothing is in fact happening');
-               $this->cli_options[] = array('--YES', 'Implicit YES to all questions', 'Use this with EXTREME care. The option "-i" is not affected by this option.');
-               $this->cli_options[] = array('-i', 'Interactive', 'Will ask you before running the AUTOFIX on each element.');
-               $this->cli_options[] = array('--filterRegex expr', 'Define an expression for preg_match() that must match the element ID in order to auto repair it', 'The element ID is the string in quotation marks when the text \'Cleaning ... in "ELEMENT ID"\'. "expr" is the expression for preg_match(). To match for example "Nature3.JPG" and "Holiday3.JPG" you can use "/.*3.JPG/". To match for example "Image.jpg" and "Image.JPG" you can use "/.*.jpg/i". Try a --dryrun first to see what the matches are!');
-               $this->cli_options[] = array('--showhowto', 'Displays HOWTO file for cleaner script.');
-               // Setting help texts:
-               $this->cli_help['name'] = 'lowlevel_cleaner -- Analysis and clean-up tools for TYPO3 installations';
-               $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
-               $this->cli_help['description'] = 'Dispatches to various analysis and clean-up tools which can plug into the API of this script. Typically you can run tests that will take longer than the usual max execution time of PHP. Such tasks could be checking for orphan records in the page tree or flushing all published versions in the system. For the complete list of options, please explore each of the \'toolkey\' keywords below:
-
-  ' . implode('
-  ', array_keys($this->cleanerModules));
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner missing_files -s -r
-This will show you missing files in the TYPO3 system and only report back if errors were found.';
-               $this->cli_help['author'] = 'Kasper Skaarhoej, (c) 2006';
-       }
-
-       /**************************
-        *
-        * CLI functionality
-        *
-        *************************/
-       /**
-        * CLI engine
-        *
-        * @param array $argv Command line arguments
-        * @return string
-        * @todo Define visibility
-        */
-       public function cli_main($argv) {
-               // Force user to admin state and set workspace to "Live":
-               $GLOBALS['BE_USER']->user['admin'] = 1;
-               $GLOBALS['BE_USER']->setWorkspace(0);
-               // Print Howto:
-               if ($this->cli_isArg('--showhowto')) {
-                       $howto = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Extension\ExtensionManager::extPath('lowlevel') . 'HOWTO_clean_up_TYPO3_installations.txt');
-                       echo wordwrap($howto, 120) . LF;
-                       die;
-               }
-               // Print help
-               $analysisType = (string) $this->cli_args['_DEFAULT'][1];
-               if (!$analysisType) {
-                       $this->cli_validateArgs();
-                       $this->cli_help();
-                       die;
-               }
-               // Analysis type:
-               switch ((string) $analysisType) {
-               default:
-                       if (is_array($this->cleanerModules[$analysisType])) {
-                               $cleanerMode = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($this->cleanerModules[$analysisType][0]);
-                               $cleanerMode->cli_validateArgs();
-                               // Run it...
-                               if ($this->cli_isArg('-r')) {
-                                       if (!$cleanerMode->checkRefIndex || $this->cli_referenceIndexCheck()) {
-                                               $res = $cleanerMode->main();
-                                               $this->cli_printInfo($analysisType, $res);
-                                               // Autofix...
-                                               if ($this->cli_isArg('--AUTOFIX')) {
-                                                       if ($this->cli_isArg('--YES') || $this->cli_keyboardInput_yes('
-
-NOW Running --AUTOFIX on result. OK?' . ($this->cli_isArg('--dryrun') ? ' (--dryrun simulation)' : ''))) {
-                                                               $cleanerMode->main_autofix($res);
-                                                       } else {
-                                                               $this->cli_echo('ABORTING AutoFix...
-', 1);
-                                                       }
-                                               }
-                                       }
-                               } else {
-                                       // Help only...
-                                       $cleanerMode->cli_help();
-                                       die;
-                               }
-                       } else {
-                               $this->cli_echo('ERROR: Analysis Type \'' . $analysisType . '\' is unknown.
-', 1);
-                               die;
-                       }
-                       break;
-               }
-       }
-
-       /**
-        * Checks reference index
-        *
-        * @return boolean TRUE if reference index was OK (either OK, updated or ignored)
-        * @todo Define visibility
-        */
-       public function cli_referenceIndexCheck() {
-               // Reference index option:
-               $refIndexMode = isset($this->cli_args['--refindex']) ? $this->cli_args['--refindex'][0] : 'check';
-               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('update,ignore,check', $refIndexMode)) {
-                       $this->cli_echo('ERROR: Wrong value for --refindex argument.
-', 1);
-                       die;
-               }
-               switch ($refIndexMode) {
-               case 'check':
-
-               case 'update':
-                       $refIndexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                       list($headerContent, $bodyContent, $errorCount) = $refIndexObj->updateIndex($refIndexMode == 'check', $this->cli_echo());
-                       if ($errorCount && $refIndexMode == 'check') {
-                               $ok = FALSE;
-                               $this->cli_echo('ERROR: Reference Index Check failed! (run with \'--refindex update\' to fix)
-', 1);
-                       } else {
-                               $ok = TRUE;
-                       }
-                       break;
-               case 'ignore':
-                       $this->cli_echo('Reference Index Check: Bypassing reference index check...
-');
-                       $ok = TRUE;
-                       break;
-               }
-               return $ok;
-       }
-
-       /**
-        * @param string $matchString
-        * @return string If string, it's the reason for not executing. Returning FALSE means it should execute.
-        * @todo Define visibility
-        */
-       public function cli_noExecutionCheck($matchString) {
-               // Check for filter:
-               if ($this->cli_isArg('--filterRegex') && ($regex = $this->cli_argValue('--filterRegex', 0))) {
-                       if (!preg_match($regex, $matchString)) {
-                               return 'BYPASS: Filter Regex "' . $regex . '" did not match string "' . $matchString . '"';
-                       }
-               }
-               // Check for interactive mode
-               if ($this->cli_isArg('-i')) {
-                       if (!$this->cli_keyboardInput_yes(' EXECUTE?')) {
-                               return 'BYPASS...';
-                       }
-               }
-               // Check for
-               if ($this->cli_isArg('--dryrun')) {
-                       return 'BYPASS: --dryrun set';
-               }
-       }
-
-       /**
-        * Formats a result array from a test so it fits output in the shell
-        *
-        * @param string $header Name of the test (eg. function name)
-        * @param array $res Result array from an analyze function
-        * @return void Outputs with echo - capture content with output buffer if needed.
-        * @todo Define visibility
-        */
-       public function cli_printInfo($header, $res) {
-               $detailLevel = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_isArg('-v') ? $this->cli_argValue('-v') : 1, 0, 3);
-               $silent = !$this->cli_echo();
-               $severity = array(
-                       0 => 'MESSAGE',
-                       1 => 'INFO',
-                       2 => 'WARNING',
-                       3 => 'ERROR'
-               );
-               // Header output:
-               if ($detailLevel <= 1) {
-                       $this->cli_echo('*********************************************
-' . $header . LF . '*********************************************
-');
-                       $this->cli_echo(wordwrap(trim($res['message'])) . LF . LF);
-               }
-               // Traverse headers for output:
-               if (is_array($res['headers'])) {
-                       foreach ($res['headers'] as $key => $value) {
-                               if ($detailLevel <= intval($value[2])) {
-                                       if (is_array($res[$key]) && (count($res[$key]) || !$silent)) {
-                                               // Header and explanaion:
-                                               $this->cli_echo('---------------------------------------------' . LF, 1);
-                                               $this->cli_echo('[' . $header . ']' . LF, 1);
-                                               $this->cli_echo($value[0] . ' [' . $severity[$value[2]] . ']' . LF, 1);
-                                               $this->cli_echo('---------------------------------------------' . LF, 1);
-                                               if (trim($value[1])) {
-                                                       $this->cli_echo('Explanation: ' . wordwrap(trim($value[1])) . LF . LF, 1);
-                                               }
-                                       }
-                                       // Content:
-                                       if (is_array($res[$key])) {
-                                               if (count($res[$key])) {
-                                                       if ($this->cli_echo('', 1)) {
-                                                               print_r($res[$key]);
-                                                       }
-                                               } else {
-                                                       $this->cli_echo('(None)' . LF . LF);
-                                               }
-                                       } else {
-                                               $this->cli_echo($res[$key] . LF . LF);
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**************************
-        *
-        * Page tree traversal
-        *
-        *************************/
-       /**
-        * Traverses the FULL/part of page tree, mainly to register ALL validly connected records (to find orphans) but also to register deleted records, versions etc.
-        * Output (in $this->recStats) can be useful for multiple purposes.
-        *
-        * @param integer $rootID Root page id from where to start traversal. Use "0" (zero) to have full page tree (necessary when spotting orphans, otherwise you can run it on parts only)
-        * @param integer $depth Depth to traverse. zero is do not traverse at all. 1 = 1 sublevel, 1000= 1000 sublevels (all...)
-        * @param boolean $echoLevel If >0, will echo information about the traversal process.
-        * @param string $callBack Call back function (from this class or subclass)
-        * @return void
-        * @todo Define visibility
-        */
-       public function genTree($rootID, $depth = 1000, $echoLevel = 0, $callBack = '') {
-               $pt = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-               $this->performanceStatistics['genTree()'] = '';
-               // Initialize:
-               if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('workspaces')) {
-                       $this->workspaceIndex = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title', 'sys_workspace', '1=1' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_workspace'), '', '', '', 'uid');
-               }
-               $this->workspaceIndex[-1] = TRUE;
-               $this->workspaceIndex[0] = TRUE;
-               $this->recStats = array(
-                       'all' => array(),
-                       // All records connected in tree including versions (the reverse are orphans). All Info and Warning categories below are included here (and therefore safe if you delete the reverse of the list)
-                       'deleted' => array(),
-                       // Subset of "alL" that are deleted-flagged [Info]
-                       'versions' => array(),
-                       // Subset of "all" which are offline versions (pid=-1). [Info]
-                       'versions_published' => array(),
-                       // Subset of "versions" that is a count of 1 or more (has been published) [Info]
-                       'versions_liveWS' => array(),
-                       // Subset of "versions" that exists in live workspace [Info]
-                       'versions_lost_workspace' => array(),
-                       // Subset of "versions" that doesn't belong to an existing workspace [Warning: Fix by move to live workspace]
-                       'versions_inside_versioned_page' => array(),
-                       // Subset of "versions" This is versions of elements found inside an already versioned branch / page. In real life this can work out, but is confusing and the backend should prevent this from happening to people. [Warning: Fix by deleting those versions (or publishing them)]
-                       'illegal_record_under_versioned_page' => array(),
-                       // If a page is "element" or "page" version and records are found attached to it, they might be illegally attached, so this will tell you. [Error: Fix by deleting orphans since they are not registered in "all" category]
-                       'misplaced_at_rootlevel' => array(),
-                       // Subset of "all": Those that should not be at root level but are. [Warning: Fix by moving record into page tree]
-                       'misplaced_inside_tree' => array()
-               );
-               // Start traversal:
-               $pt2 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-               $this->performanceStatistics['genTree_traverse()'] = '';
-               $this->performanceStatistics['genTree_traverse():TraverseTables'] = '';
-               $this->genTree_traverse($rootID, $depth, $echoLevel, $callBack);
-               $this->performanceStatistics['genTree_traverse()'] = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt2;
-               // Sort recStats (for diff'able displays)
-               foreach ($this->recStats as $kk => $vv) {
-                       foreach ($this->recStats[$kk] as $tables => $recArrays) {
-                               ksort($this->recStats[$kk][$tables]);
-                       }
-                       ksort($this->recStats[$kk]);
-               }
-               if ($echoLevel > 0) {
-                       echo LF . LF;
-               }
-               // Processing performance statistics:
-               $this->performanceStatistics['genTree()'] = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt;
-               // Count records:
-               foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
-                       // Select all records belonging to page:
-                       $resSub = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tableName, '');
-                       $countRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSub);
-                       $this->performanceStatistics['MySQL_count'][$tableName] = $countRow['count(*)'];
-                       $this->performanceStatistics['CSV'] .= LF . $tableName . ',' . $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL'][$tableName] . ',' . $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc'][$tableName] . ',' . $this->performanceStatistics['MySQL_count'][$tableName];
-               }
-               $this->performanceStatistics['recStats_size']['(ALL)'] = strlen(serialize($this->recStats));
-               foreach ($this->recStats as $key => $arrcontent) {
-                       $this->performanceStatistics['recStats_size'][$key] = strlen(serialize($arrcontent));
-               }
-       }
-
-       /**
-        * Recursive traversal of page tree:
-        *
-        * @param integer $rootID Page root id (must be online, valid page record - or zero for page tree root)
-        * @param integer $depth Depth
-        * @param integer $echoLevel Echo Level
-        * @param string $callBack Call back function (from this class or subclass)
-        * @param string $versionSwapmode DON'T set from outside, internal. (indicates we are inside a version of a page) - will be "SWAPMODE:-1" or empty
-        * @param integer $rootIsVersion DON'T set from outside, internal. (1: Indicates that rootID is a version of a page, 2: ...that it is even a version of a version (which triggers a warning!)
-        * @param string $accumulatedPath Internal string that accumulates the path
-        * @return void
-        * @access private
-        * @todo $versionSwapmode needs to be cleaned up, since page and branch version (0, 1) does not exist anymore
-        * @todo Define visibility
-        */
-       public function genTree_traverse($rootID, $depth, $echoLevel = 0, $callBack = '', $versionSwapmode = '', $rootIsVersion = 0, $accumulatedPath = '') {
-               // Register page:
-               $this->recStats['all']['pages'][$rootID] = $rootID;
-               $pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw('pages', 'uid=' . intval($rootID), 'deleted,title,t3ver_count,t3ver_wsid');
-               $accumulatedPath .= '/' . $pageRecord['title'];
-               // Register if page is deleted:
-               if ($pageRecord['deleted']) {
-                       $this->recStats['deleted']['pages'][$rootID] = $rootID;
-               }
-               // If rootIsVersion is set it means that the input rootID is that of a version of a page. See below where the recursive call is made.
-               if ($rootIsVersion) {
-                       $this->recStats['versions']['pages'][$rootID] = $rootID;
-                       // If it has been published and is in archive now...
-                       if ($pageRecord['t3ver_count'] >= 1 && $pageRecord['t3ver_wsid'] == 0) {
-                               $this->recStats['versions_published']['pages'][$rootID] = $rootID;
-                       }
-                       // If it has been published and is in archive now...
-                       if ($pageRecord['t3ver_wsid'] == 0) {
-                               $this->recStats['versions_liveWS']['pages'][$rootID] = $rootID;
-                       }
-                       // If it doesn't belong to a workspace...
-                       if (!isset($this->workspaceIndex[$pageRecord['t3ver_wsid']])) {
-                               $this->recStats['versions_lost_workspace']['pages'][$rootID] = $rootID;
-                       }
-                       // In case the rootID is a version inside a versioned page
-                       if ($rootIsVersion == 2) {
-                               $this->recStats['versions_inside_versioned_page']['pages'][$rootID] = $rootID;
-                       }
-               }
-               if ($echoLevel > 0) {
-                       echo LF . $accumulatedPath . ' [' . $rootID . ']' . ($pageRecord['deleted'] ? ' (DELETED)' : '') . ($this->recStats['versions_published']['pages'][$rootID] ? ' (PUBLISHED)' : '');
-               }
-               if ($echoLevel > 1 && $this->recStats['versions_lost_workspace']['pages'][$rootID]) {
-                       echo LF . '     ERROR! This version belongs to non-existing workspace (' . $pageRecord['t3ver_wsid'] . ')!';
-               }
-               if ($echoLevel > 1 && $this->recStats['versions_inside_versioned_page']['pages'][$rootID]) {
-                       echo LF . '     WARNING! This version is inside an already versioned page or branch!';
-               }
-               // Call back:
-               if ($callBack) {
-                       $this->{$callBack}('pages', $rootID, $echoLevel, $versionSwapmode, $rootIsVersion);
-               }
-               $pt3 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-               // Traverse tables of records that belongs to page:
-               foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
-                       if ($tableName != 'pages') {
-                               // Select all records belonging to page:
-                               $pt4 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-                               $resSub = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid' . ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] : ''), $tableName, 'pid=' . intval($rootID) . ($this->genTree_traverseDeleted ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableName)));
-                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL']['(ALL)'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt4;
-                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL'][$tableName] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt4;
-                               $pt5 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-                               $count = $GLOBALS['TYPO3_DB']->sql_num_rows($resSub);
-                               if ($count) {
-                                       if ($echoLevel == 2) {
-                                               echo LF . '     \\-' . $tableName . ' (' . $count . ')';
-                                       }
-                               }
-                               while ($rowSub = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSub)) {
-                                       if ($echoLevel == 3) {
-                                               echo LF . '     \\-' . $tableName . ':' . $rowSub['uid'];
-                                       }
-                                       // If the rootID represents an "element" or "page" version type, we must check if the record from this table is allowed to belong to this:
-                                       if ($versionSwapmode == 'SWAPMODE:-1' || $versionSwapmode == 'SWAPMODE:0' && !$GLOBALS['TCA'][$tableName]['ctrl']['versioning_followPages']) {
-                                               // This is illegal records under a versioned page - therefore not registered in $this->recStats['all'] so they should be orphaned:
-                                               $this->recStats['illegal_record_under_versioned_page'][$tableName][$rowSub['uid']] = $rowSub['uid'];
-                                               if ($echoLevel > 1) {
-                                                       echo LF . '             ERROR! Illegal record (' . $tableName . ':' . $rowSub['uid'] . ') under versioned page!';
-                                               }
-                                       } else {
-                                               $this->recStats['all'][$tableName][$rowSub['uid']] = $rowSub['uid'];
-                                               // Register deleted:
-                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $rowSub[$GLOBALS['TCA'][$tableName]['ctrl']['delete']]) {
-                                                       $this->recStats['deleted'][$tableName][$rowSub['uid']] = $rowSub['uid'];
-                                                       if ($echoLevel == 3) {
-                                                               echo ' (DELETED)';
-                                                       }
-                                               }
-                                               // Check location of records regarding tree root:
-                                               if (!$GLOBALS['TCA'][$tableName]['ctrl']['rootLevel'] && $rootID == 0) {
-                                                       $this->recStats['misplaced_at_rootlevel'][$tableName][$rowSub['uid']] = $rowSub['uid'];
-                                                       if ($echoLevel > 1) {
-                                                               echo LF . '             ERROR! Misplaced record (' . $tableName . ':' . $rowSub['uid'] . ') on rootlevel!';
-                                                       }
-                                               }
-                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['rootLevel'] == 1 && $rootID > 0) {
-                                                       $this->recStats['misplaced_inside_tree'][$tableName][$rowSub['uid']] = $rowSub['uid'];
-                                                       if ($echoLevel > 1) {
-                                                               echo LF . '             ERROR! Misplaced record (' . $tableName . ':' . $rowSub['uid'] . ') inside page tree!';
-                                                       }
-                                               }
-                                               // Traverse plugins:
-                                               if ($callBack) {
-                                                       $this->{$callBack}($tableName, $rowSub['uid'], $echoLevel, $versionSwapmode, $rootIsVersion);
-                                               }
-                                               // Add any versions of those records:
-                                               if ($this->genTree_traverseVersions) {
-                                                       $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord($tableName, $rowSub['uid'], 'uid,t3ver_wsid,t3ver_count' . ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] : ''), 0, TRUE);
-                                                       if (is_array($versions)) {
-                                                               foreach ($versions as $verRec) {
-                                                                       if (!$verRec['_CURRENT_VERSION']) {
-                                                                               if ($echoLevel == 3) {
-                                                                                       echo LF . '             \\-[#OFFLINE VERSION: WS#' . $verRec['t3ver_wsid'] . '/Cnt:' . $verRec['t3ver_count'] . '] ' . $tableName . ':' . $verRec['uid'] . ')';
-                                                                               }
-                                                                               $this->recStats['all'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                               // Register deleted:
-                                                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $verRec[$GLOBALS['TCA'][$tableName]['ctrl']['delete']]) {
-                                                                                       $this->recStats['deleted'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                                       if ($echoLevel == 3) {
-                                                                                               echo ' (DELETED)';
-                                                                                       }
-                                                                               }
-                                                                               // Register version:
-                                                                               $this->recStats['versions'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                               if ($verRec['t3ver_count'] >= 1 && $verRec['t3ver_wsid'] == 0) {
-                                                                                       // Only register published versions in LIVE workspace (published versions in draft workspaces are allowed)
-                                                                                       $this->recStats['versions_published'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                                       if ($echoLevel == 3) {
-                                                                                               echo ' (PUBLISHED)';
-                                                                                       }
-                                                                               }
-                                                                               if ($verRec['t3ver_wsid'] == 0) {
-                                                                                       $this->recStats['versions_liveWS'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                               }
-                                                                               if (!isset($this->workspaceIndex[$verRec['t3ver_wsid']])) {
-                                                                                       $this->recStats['versions_lost_workspace'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                                       if ($echoLevel > 1) {
-                                                                                               echo LF . '             ERROR! Version (' . $tableName . ':' . $verRec['uid'] . ') belongs to non-existing workspace (' . $verRec['t3ver_wsid'] . ')!';
-                                                                                       }
-                                                                               }
-                                                                               // In case we are inside a versioned branch, there should not exists versions inside that "branch".
-                                                                               if ($versionSwapmode) {
-                                                                                       $this->recStats['versions_inside_versioned_page'][$tableName][$verRec['uid']] = $verRec['uid'];
-                                                                                       if ($echoLevel > 1) {
-                                                                                               echo LF . '             ERROR! This version (' . $tableName . ':' . $verRec['uid'] . ') is inside an already versioned page or branch!';
-                                                                                       }
-                                                                               }
-                                                                               // Traverse plugins:
-                                                                               if ($callBack) {
-                                                                                       $this->{$callBack}($tableName, $verRec['uid'], $echoLevel, $versionSwapmode, $rootIsVersion);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                                       unset($versions);
-                                               }
-                                       }
-                               }
-                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc']['(ALL)'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt5;
-                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc'][$tableName] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt5;
-                       }
-               }
-               unset($resSub);
-               unset($rowSub);
-               $this->performanceStatistics['genTree_traverse():TraverseTables'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt3;
-               // Find subpages to root ID and traverse (only when rootID is not a version or is a branch-version):
-               if (!$versionSwapmode || $versionSwapmode == 'SWAPMODE:1') {
-                       if ($depth > 0) {
-                               $depth--;
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . intval($rootID) . ($this->genTree_traverseDeleted ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('pages')), '', 'sorting');
-                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                       $this->genTree_traverse($row['uid'], $depth, $echoLevel, $callBack, $versionSwapmode, 0, $accumulatedPath);
-                               }
-                       }
-                       // Add any versions of pages
-                       if ($rootID > 0 && $this->genTree_traverseVersions) {
-                               $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord('pages', $rootID, 'uid,t3ver_oid,t3ver_wsid,t3ver_count', 0, TRUE);
-                               if (is_array($versions)) {
-                                       foreach ($versions as $verRec) {
-                                               if (!$verRec['_CURRENT_VERSION']) {
-                                                       $this->genTree_traverse($verRec['uid'], $depth, $echoLevel, $callBack, 'SWAPMODE:-1', $versionSwapmode ? 2 : 1, $accumulatedPath . ' [#OFFLINE VERSION: WS#' . $verRec['t3ver_wsid'] . '/Cnt:' . $verRec['t3ver_count'] . ']');
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**************************
-        *
-        * Helper functions
-        *
-        *************************/
-       /**
-        * Compile info-string
-        *
-        * @param array $rec Input record from sys_refindex
-        * @return string String identifying the main record of the reference
-        * @todo Define visibility
-        */
-       public function infoStr($rec) {
-               return $rec['tablename'] . ':' . $rec['recuid'] . ':' . $rec['field'] . ':' . $rec['flexpointer'] . ':' . $rec['softref_key'] . ($rec['deleted'] ? ' (DELETED)' : '');
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/DeletedRecordsCommand.php b/typo3/sysext/integrity/Classes/DeletedRecordsCommand.php
deleted file mode 100644 (file)
index cade063..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Deleted records
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for Deleted records
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class DeletedRecordsCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $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.');
-               $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
-               $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.');
-               $this->cli_help['name'] = 'deleted -- To find and flush deleted records in the page tree';
-               $this->cli_help['description'] = trim('
-Traversing page tree and finding deleted records
-
-Automatic Repair:
-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.
-');
-               $this->cli_help['examples'] = '';
-       }
-
-       /**
-        * Find orphan records
-        * VERY CPU and memory intensive since it will look up the whole page tree!
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               '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)
-                       ),
-                       'deleted' => array()
-               );
-               $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
-               $depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
-               $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'));
-               $resultArray['deleted'] = $this->recStats['deleted'];
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               // Putting "tx_templavoila_datastructure" table in the bottom:
-               if (isset($resultArray['deleted']['tx_templavoila_datastructure'])) {
-                       $_tx_templavoila_datastructure = $resultArray['deleted']['tx_templavoila_datastructure'];
-                       unset($resultArray['deleted']['tx_templavoila_datastructure']);
-                       $resultArray['deleted']['tx_templavoila_datastructure'] = $_tx_templavoila_datastructure;
-               }
-               // Putting "pages" table in the bottom:
-               if (isset($resultArray['deleted']['pages'])) {
-                       $_pages = $resultArray['deleted']['pages'];
-                       unset($resultArray['deleted']['pages']);
-                       // To delete sub pages first assuming they are accumulated from top of page tree.
-                       $resultArray['deleted']['pages'] = array_reverse($_pages);
-               }
-               // Traversing records:
-               foreach ($resultArray['deleted'] as $table => $list) {
-                       echo 'Flushing deleted records from table "' . $table . '":' . LF;
-                       foreach ($list as $uid) {
-                               echo '  Flushing record "' . $table . ':' . $uid . '": ';
-                               if ($bypass = $this->cli_noExecutionCheck($table . ':' . $uid)) {
-                                       echo $bypass;
-                               } else {
-                                       // Execute CMD array:
-                                       $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
-                                       $tce->stripslashes_values = FALSE;
-                                       $tce->start(array(), array());
-                                       // Notice, we are deleting pages with no regard to subpages/subrecords - we do this since they
-                                       // should also be included in the set of deleted pages of course (no un-deleted record can exist
-                                       // under a deleted page...)
-                                       $tce->deleteRecord($table, $uid, TRUE, TRUE);
-                                       // Return errors if any:
-                                       if (count($tce->errorLog)) {
-                                               echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
-                                       } else {
-                                               echo 'DONE';
-                                       }
-                               }
-                               echo LF;
-                       }
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/DoubleFilesCommand.php b/typo3/sysext/integrity/Classes/DoubleFilesCommand.php
deleted file mode 100644 (file)
index fc40d60..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Double Files
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for double files
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class DoubleFilesCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * @todo Define visibility
-        */
-       public $checkRefIndex = TRUE;
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $this->cli_help['name'] = 'double_files -- Looking for files from TYPO3 managed records which are referenced more than one time (only one time allowed)';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- a perfect integrity of the reference index table (always update the reference index table before using this tool!)
-- files found in deleted records are included (otherwise you would see a false list of lost files)
-
-Files attached to records in TYPO3 using a "group" type configuration in TCA or FlexForm DataStructure are managed exclusively by the system and there must always exist a 1-1 reference between the file and the reference in the record.
-This tool will expose when such files are referenced from multiple locations which is considered an integrity error.
-If a multi-reference is found it was typically created because the record was copied or modified outside of TCEmain which will otherwise maintain the relations correctly.
-Multi-references should be resolved to 1-1 references as soon as possible. The danger of keeping multi-references is that if the file is removed from one of the refering records it will actually be deleted in the file system, leaving missing files for the remaining referers!
-
-Automatic Repair of Errors:
-- The multi-referenced file is copied under a new name and references updated.
-
-Manual repair suggestions:
-- None that can not be handled by the automatic repair.
-');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner double_files -s -r
-This will check the system for double files relations.';
-       }
-
-       /**
-        * Find managed files which are referred to more than one time
-        * Fix methods: API in t3lib_refindex that allows to change the value of a reference (we could copy the file) or remove reference
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'multipleReferencesList_count' => array('Number of multi-reference files', '(See below)', 0),
-                               'singleReferencesList_count' => array('Number of files correctly referenced', 'The amount of correct 1-1 references', 0),
-                               'multipleReferencesList' => array('Entries with files having multiple references', 'These are serious problems that should be resolved ASAP to prevent data loss! ' . $this->label_infoString, 3),
-                               'dirname_registry' => array('Registry of directories in which files are found.', 'Registry includes which table/field pairs store files in them plus how many files their store.', 0),
-                               'missingFiles' => array('Tracking missing files', '(Extra feature, not related to tracking of double references. Further, the list may include more files than found in the missing_files()-test because this list includes missing files from deleted records.)', 0),
-                               'warnings' => array('Warnings picked up', '', 2)
-                       ),
-                       'multipleReferencesList_count' => array('count' => 0),
-                       'singleReferencesList_count' => array('count' => 0),
-                       'multipleReferencesList' => array(),
-                       'dirname_registry' => array(),
-                       'missingFiles' => array(),
-                       'warnings' => array()
-               );
-               // Select all files in the reference table not found by a soft reference parser (thus TCA configured)
-               $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
-               // Traverse the files and put into a large table:
-               $tempCount = array();
-               if (is_array($recs)) {
-                       foreach ($recs as $rec) {
-                               // Compile info string for location of reference:
-                               $infoString = $this->infoStr($rec);
-                               // Registering occurencies in directories:
-                               $resultArray['dirname_registry'][dirname($rec['ref_string'])][($rec['tablename'] . ':' . $rec['field'])]++;
-                               // Handle missing file:
-                               if (!@is_file((PATH_site . $rec['ref_string']))) {
-                                       $resultArray['missingFiles'][$rec['ref_string']][$rec['hash']] = $infoString;
-                                       ksort($resultArray['missingFiles'][$rec['ref_string']]);
-                               }
-                               // Add entry if file has multiple references pointing to it:
-                               if (isset($tempCount[$rec['ref_string']])) {
-                                       if (!is_array($resultArray['multipleReferencesList'][$rec['ref_string']])) {
-                                               $resultArray['multipleReferencesList'][$rec['ref_string']] = array();
-                                               $resultArray['multipleReferencesList'][$rec['ref_string']][$tempCount[$rec['ref_string']][1]] = $tempCount[$rec['ref_string']][0];
-                                       }
-                                       $resultArray['multipleReferencesList'][$rec['ref_string']][$rec['hash']] = $infoString;
-                                       ksort($resultArray['multipleReferencesList'][$rec['ref_string']]);
-                               } else {
-                                       $tempCount[$rec['ref_string']] = array($infoString, $rec['hash']);
-                               }
-                       }
-               }
-               ksort($resultArray['missingFiles']);
-               ksort($resultArray['multipleReferencesList']);
-               // Add count for multi-references:
-               $resultArray['multipleReferencesList_count']['count'] = count($resultArray['multipleReferencesList']);
-               $resultArray['singleReferencesList_count']['count'] = count($tempCount) - $resultArray['multipleReferencesList_count']['count'];
-               // Sort dirname registry and add warnings for directories outside uploads/
-               ksort($resultArray['dirname_registry']);
-               foreach ($resultArray['dirname_registry'] as $dir => $temp) {
-                       ksort($resultArray['dirname_registry'][$dir]);
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($dir, 'uploads/')) {
-                               $resultArray['warnings'][\TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($dir)] = 'Directory "' . $dir . '" was outside uploads/ which is unusual practice in TYPO3 although not forbidden. Directory used by the following table:field pairs: ' . implode(',', array_keys($temp));
-                       }
-               }
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               foreach ($resultArray['multipleReferencesList'] as $key => $value) {
-                       $absFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($key);
-                       if ($absFileName && @is_file($absFileName)) {
-                               echo 'Processing file: ' . $key . LF;
-                               $c = 0;
-                               foreach ($value as $hash => $recReference) {
-                                       if ($c == 0) {
-                                               echo '  Keeping ' . $key . ' for record "' . $recReference . '"' . LF;
-                                       } else {
-                                               // Create unique name for file:
-                                               $fileFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
-                                               $newName = $fileFunc->getUniqueName(basename($key), dirname($absFileName));
-                                               echo '  Copying ' . $key . ' to ' . substr($newName, strlen(PATH_site)) . ' for record "' . $recReference . '": ';
-                                               if ($bypass = $this->cli_noExecutionCheck($recReference)) {
-                                                       echo $bypass;
-                                               } else {
-                                                       \TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move($absFileName, $newName);
-                                                       clearstatcache();
-                                                       if (@is_file($newName)) {
-                                                               $sysRefObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                                               $error = $sysRefObj->setReferenceValue($hash, basename($newName));
-                                                               if ($error) {
-                                                                       echo '  ERROR:  TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
-                                                                       die;
-                                                               } else {
-                                                                       echo 'DONE';
-                                                               }
-                                                       } else {
-                                                               echo '  ERROR: File "' . $newName . '" was not created!';
-                                                       }
-                                               }
-                                               echo LF;
-                                       }
-                                       $c++;
-                               }
-                       } else {
-                               echo '  ERROR: File "' . $absFileName . '" was not found!';
-                       }
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/LostFilesCommand.php b/typo3/sysext/integrity/Classes/LostFilesCommand.php
deleted file mode 100644 (file)
index 4096ebb..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Lost files
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for Lost files
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class LostFilesCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * @todo Define visibility
-        */
-       public $checkRefIndex = TRUE;
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               $this->cli_options[] = array('--excludePath [path-list]', 'Comma separated list of paths to exclude. Example: "uploads/[path1],uploads/[path2],..."');
-               // Setting up help:
-               $this->cli_help['name'] = 'lost_files -- Looking for files in the uploads/ folder which does not have a reference in TYPO3 managed records.';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- a perfect integrity of the reference index table (always update the reference index table before using this tool!)
-- that all contents in the uploads folder are files attached to TCA records and exclusively managed by TCEmain through "group" type fields
-- exceptions are: index.html and .htaccess files (ignored)
-- exceptions are: RTEmagic* image files (ignored)
-- files found in deleted records are included (otherwise you would see a false list of lost files)
-
-The assumptions are not requirements by the TYPO3 API but reflects the de facto implementation of most TYPO3 installations and therefore a practical approach to cleaning up the uploads/ folder.
-Therefore, if all "group" type fields in TCA and flexforms are positioned inside the uploads/ folder and if no files inside are managed manually it should be safe to clean out files with no relations found in the system.
-Under such circumstances there should theoretically be no lost files in the uploads/ folder since TCEmain should have managed relations automatically including adding and deleting files.
-However, there is at least one reason known to why files might be found lost and that is when FlexForms are used. In such a case a change of/in the Data Structure XML (or the ability of the system to find the Data Structure definition!) used for the flexform could leave lost files behind. This is not unlikely to happen when records are deleted. More details can be found in a note to the function TYPO3\\CMS\\Backend\\Utility\\BackendUtility::getFlexFormDS()
-Another scenario could of course be de-installation of extensions which managed files in the uploads/ folders.
-
-Automatic Repair of Errors:
-- Simply delete lost files (Warning: First, make sure those files are not used somewhere TYPO3 does not know about! See the assumptions above).
-');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner lost_files -s -r
-Will report lost files.';
-       }
-
-       /**
-        * Find lost files in uploads/ folder
-        * FIX METHOD: Simply delete the file...
-        *
-        * TODO: Add parameter to exclude filepath
-        * TODO: Add parameter to list more file names/patterns to ignore
-        * TODO: Add parameter to include RTEmagic images
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0),
-                               'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0),
-                               'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0),
-                               'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3),
-                               'warnings' => array('Warnings picked up', '', 2)
-                       ),
-                       'managedFiles' => array(),
-                       'ignoredFiles' => array(),
-                       'RTEmagicFiles' => array(),
-                       'lostFiles' => array(),
-                       'warnings' => array()
-               );
-               // Get all files:
-               $fileArr = array();
-               $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/');
-               $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($fileArr, PATH_site);
-               $excludePaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->cli_argValue('--excludePath', 0), 1);
-               // Traverse files and for each, look up if its found in the reference index.
-               foreach ($fileArr as $key => $value) {
-                       $include = TRUE;
-                       foreach ($excludePaths as $exclPath) {
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($value, $exclPath)) {
-                                       $include = FALSE;
-                               }
-                       }
-                       $shortKey = \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($value);
-                       if ($include) {
-                               // First, allow "index.html", ".htaccess" files since they are often used for good reasons
-                               if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') {
-                                       unset($fileArr[$key]);
-                                       $resultArray['ignoredFiles'][$shortKey] = $value;
-                               } else {
-                                       // Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration)
-                                       $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $TYPO3_DB->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
-                                       // If found, unset entry:
-                                       if (count($recs)) {
-                                               unset($fileArr[$key]);
-                                               $resultArray['managedFiles'][$shortKey] = $value;
-                                               if (count($recs) > 1) {
-                                                       $resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!';
-                                               }
-                                       } else {
-                                               // When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it:
-                                               if (preg_match('/^RTEmagic[P|C]_/', basename($value))) {
-                                                       unset($fileArr[$key]);
-                                                       $resultArray['RTEmagicFiles'][$shortKey] = $value;
-                                               } else {
-                                                       // We conclude that the file is lost...:
-                                                       unset($fileArr[$key]);
-                                                       $resultArray['lostFiles'][$shortKey] = $value;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               asort($resultArray['ignoredFiles']);
-               asort($resultArray['managedFiles']);
-               asort($resultArray['RTEmagicFiles']);
-               asort($resultArray['lostFiles']);
-               asort($resultArray['warnings']);
-               // $fileArr variable should now be empty with all contents transferred to the result array keys.
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               foreach ($resultArray['lostFiles'] as $key => $value) {
-                       $absFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($value);
-                       echo 'Deleting file: "' . $absFileName . '": ';
-                       if ($bypass = $this->cli_noExecutionCheck($absFileName)) {
-                               echo $bypass;
-                       } else {
-                               if ($absFileName && @is_file($absFileName)) {
-                                       unlink($absFileName);
-                                       echo 'DONE';
-                               } else {
-                                       echo '  ERROR: File "' . $absFileName . '" was not found!';
-                               }
-                       }
-                       echo LF;
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/MissingFilesCommand.php b/typo3/sysext/integrity/Classes/MissingFilesCommand.php
deleted file mode 100644 (file)
index 10c5052..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Missing files
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for missing files.
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class MissingFilesCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * @todo Define visibility
-        */
-       public $checkRefIndex = TRUE;
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $this->cli_help['name'] = 'missing_files -- Find all file references from records pointing to a missing (non-existing) file.';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- a perfect integrity of the reference index table (always update the reference index table before using this tool!)
-- relevant soft reference parsers applied everywhere file references are used inline
-
-Files may be missing for these reasons (except software bugs):
-- someone manually deleted the file inside fileadmin/ or another user maintained folder. If the reference was a soft reference (opposite to a TCEmain managed file relation from "group" type fields), technically it is not an error although it might be a mistake that someone did so.
-- someone manually deleted the file inside the uploads/ folder (typically containing managed files) which is an error since no user interaction should take place there.
-
-Automatic Repair of Errors:
-- Managed files (TCA/FlexForm attachments): Will silently remove the reference from the record since the file is missing. For this reason you might prefer a manual approach instead.
-- Soft References: Requires manual fix if you consider it an error.
-
-Manual repair suggestions:
-- Managed files: You might be able to locate the file and re-insert it in the correct location. However, no automatic fix can do that for you.
-- Soft References: You should investigate each case and edit the content accordingly. A soft reference to a file could be in an HTML image tag (for example <img src="missing_file.jpg" />) and you would have to either remove the whole tag, change the filename or re-create the missing file.
-');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner missing_files -s -r
-This will show you missing files in the TYPO3 system and only report back if errors were found.';
-       }
-
-       /**
-        * Find file references that points to non-existing files in system
-        * Fix methods: API in t3lib_refindex that allows to change the value of a reference (or remove it)
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $listExplain = ' Shows the relative filename of missing file as header and under a list of record fields in which the references are found. ' . $this->label_infoString;
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'managedFilesMissing' => array('List of missing files managed by TCEmain', $listExplain, 3),
-                               'softrefFilesMissing' => array('List of missing files registered as a soft reference', $listExplain, 2)
-                       ),
-                       'managedFilesMissing' => array(),
-                       'softrefFilesMissing' => array()
-               );
-               // Select all files in the reference table
-               $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex'), '', 'sorting DESC');
-               // Traverse the files and put into a large table:
-               if (is_array($recs)) {
-                       foreach ($recs as $rec) {
-                               // Compile info string for location of reference:
-                               $infoString = $this->infoStr($rec);
-                               // Handle missing file:
-                               if (!@is_file((PATH_site . $rec['ref_string']))) {
-                                       if ((string) $rec['softref_key'] == '') {
-                                               $resultArrayIndex = 'managedFilesMissing';
-                                       } else {
-                                               $resultArrayIndex = 'softrefFilesMissing';
-                                       }
-                                       $resultArray[$resultArrayIndex][$rec['ref_string']][$rec['hash']] = $infoString;
-                                       ksort($resultArray[$resultArrayIndex][$rec['ref_string']]);
-                               }
-                       }
-               }
-               ksort($resultArray['managedFilesMissing']);
-               ksort($resultArray['softrefFilesMissing']);
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               foreach ($resultArray['managedFilesMissing'] as $key => $value) {
-                       echo 'Processing file: ' . $key . LF;
-                       $c = 0;
-                       foreach ($value as $hash => $recReference) {
-                               echo '  Removing reference in record "' . $recReference . '": ';
-                               if ($bypass = $this->cli_noExecutionCheck($recReference)) {
-                                       echo $bypass;
-                               } else {
-                                       $sysRefObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                       $error = $sysRefObj->setReferenceValue($hash, NULL);
-                                       if ($error) {
-                                               echo '          TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
-                                               echo 'missing_files: exit on error' . LF;
-                                               die;
-                                       } else {
-                                               echo 'DONE';
-                                       }
-                               }
-                               echo LF;
-                       }
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/MissingRelationsCommand.php b/typo3/sysext/integrity/Classes/MissingRelationsCommand.php
deleted file mode 100644 (file)
index 9124457..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Missing relations
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for missing relations.
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class MissingRelationsCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * @todo Define visibility
-        */
-       public $checkRefIndex = TRUE;
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $this->cli_help['name'] = 'missing_relations -- Find all record references pointing to a non-existing record.';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- a perfect integrity of the reference index table (always update the reference index table before using this tool!)
-- all database references to check are integers greater than zero
-- does not check if a referenced record is inside an offline branch, another workspace etc. which could make the reference useless in reality or otherwise question integrity
-Records may be missing for these reasons (except software bugs):
-- someone deleted the record which is technically not an error although it might be a mistake that someone did so.
-- after flushing published versions and/or deleted-flagged records a number of new missing references might appear; those were pointing to records just flushed.
-
-Automatic Repair of Errors:
-- Only managed references are repaired (TCA-configured).
-- Offline Version Records and Non Existing Records: Reference is removed
-
-Manual repair suggestions:
-- For soft references you should investigate each case and edit the content accordingly.
-- References to deleted records can theoretically be removed since a deleted record cannot be selected and hence your website should not be affected by removal of the reference. On the other hand it does not hurt to ignore it for now. To have this automatically fixed you must first flush the deleted records after which remaining references will appear as pointing to Non Existing Records and can now be removed with the automatic fix.
-
-NOTICE: Uses the Reference Index Table (sys_refindex) for analysis. Update it before use!
-');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner missing_relations -s -r
-Reports missing relations';
-       }
-
-       /**
-        * Find relations pointing to non-existing records
-        * Fix methods: API in t3lib_refindex that allows to change the value of a reference (or remove it) [Only for managed relations!]
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $listExplain = ' Shows the missing record as header and underneath a list of record fields in which the references are found. ' . $this->label_infoString;
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'offlineVersionRecords_m' => array('Offline version records (managed)', 'These records are offline versions having a pid=-1 and references should never occur directly to their uids.' . $listExplain, 3),
-                               'deletedRecords_m' => array('Deleted-flagged records (managed)', 'These records are deleted with a flag but references are still pointing at them. Keeping the references is useful if you undelete the referenced records later, otherwise the references are lost completely when the deleted records are flushed at some point. Notice that if those records listed are themselves deleted (marked with "DELETED") it is not a problem.' . $listExplain, 2),
-                               'nonExistingRecords_m' => array('Non-existing records to which there are references (managed)', 'These references can safely be removed since there is no record found in the database at all.' . $listExplain, 3),
-                               // 3 = error
-                               'offlineVersionRecords_s' => array('Offline version records (softref)', 'See above.' . $listExplain, 2),
-                               'deletedRecords_s' => array('Deleted-flagged records (softref)', 'See above.' . $listExplain, 2),
-                               'nonExistingRecords_s' => array('Non-existing records to which there are references (softref)', 'See above.' . $listExplain, 2)
-                       ),
-                       'offlineVersionRecords_m' => array(),
-                       'deletedRecords_m' => array(),
-                       'nonExistingRecords_m' => array(),
-                       'offlineVersionRecords_s' => array(),
-                       'deletedRecords_s' => array(),
-                       'nonExistingRecords_s' => array()
-               );
-               // Select DB relations from reference table
-               $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table<>' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_uid>0' . $filterClause, '', 'sorting DESC');
-               // Traverse the records
-               $tempExists = array();
-               if (is_array($recs)) {
-                       foreach ($recs as $rec) {
-                               $suffix = $rec['softref_key'] != '' ? '_s' : '_m';
-                               $idx = $rec['ref_table'] . ':' . $rec['ref_uid'];
-                               // Get referenced record:
-                               if (!isset($tempExists[$idx])) {
-                                       $tempExists[$idx] = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($rec['ref_table'], 'uid=' . intval($rec['ref_uid']), 'uid,pid' . ($GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] : ''));
-                               }
-                               // Compile info string for location of reference:
-                               $infoString = $this->infoStr($rec);
-                               // Handle missing file:
-                               if ($tempExists[$idx]['uid']) {
-                                       if ($tempExists[$idx]['pid'] == -1) {
-                                               $resultArray['offlineVersionRecords' . $suffix][$idx][$rec['hash']] = $infoString;
-                                               ksort($resultArray['offlineVersionRecords' . $suffix][$idx]);
-                                       } elseif ($GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete'] && $tempExists[$idx][$GLOBALS['TCA'][$rec['ref_table']]['ctrl']['delete']]) {
-                                               $resultArray['deletedRecords' . $suffix][$idx][$rec['hash']] = $infoString;
-                                               ksort($resultArray['deletedRecords' . $suffix][$idx]);
-                                       }
-                               } else {
-                                       $resultArray['nonExistingRecords' . $suffix][$idx][$rec['hash']] = $infoString;
-                                       ksort($resultArray['nonExistingRecords' . $suffix][$idx]);
-                               }
-                       }
-               }
-               ksort($resultArray['offlineVersionRecords_m']);
-               ksort($resultArray['deletedRecords_m']);
-               ksort($resultArray['nonExistingRecords_m']);
-               ksort($resultArray['offlineVersionRecords_s']);
-               ksort($resultArray['deletedRecords_s']);
-               ksort($resultArray['nonExistingRecords_s']);
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               $trav = array('offlineVersionRecords_m', 'nonExistingRecords_m');
-               foreach ($trav as $tk) {
-                       echo 'Processing managed "' . $tk . '"...' . LF;
-                       foreach ($resultArray[$tk] as $key => $value) {
-                               foreach ($value as $hash => $recReference) {
-                                       echo '  Removing reference to ' . $key . ' in record "' . $recReference . '": ';
-                                       if ($bypass = $this->cli_noExecutionCheck($recReference)) {
-                                               echo $bypass;
-                                       } else {
-                                               $sysRefObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                               $error = $sysRefObj->setReferenceValue($hash, NULL);
-                                               if ($error) {
-                                                       echo '          TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
-                                               } else {
-                                                       echo 'DONE';
-                                               }
-                                       }
-                                       echo LF;
-                               }
-                       }
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/OrphanRecordsCommand.php b/typo3/sysext/integrity/Classes/OrphanRecordsCommand.php
deleted file mode 100644 (file)
index 1ee7359..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Orphan records
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for Orphan Records
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class OrphanRecordsCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $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.');
-               $this->cli_help['name'] = 'orphan_records -- To find records that has lost their connection with the page tree';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- That all actively used records on the website from TCA configured tables are located in the page tree exclusively.
-
-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.
-VERY TIME, CPU and MEMORY intensive operation since the full page tree is looked up!
-
-Automatic Repair of Errors:
-- 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.
-
-Manual repair suggestions:
-- 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.
-');
-               $this->cli_help['todo'] = trim('
-- 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.
-- Implement that orphans can be fixed by setting the PID to a certain page instead of deleting.');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner orphan_records -s -r
-Will report orphan uids from TCA tables.';
-       }
-
-       /**
-        * Find orphan records
-        * VERY CPU and memory intensive since it will look up the whole page tree!
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'orphans' => array('Index of orphaned records', '', 3),
-                               'misplaced_at_rootlevel' => array('Records that should not be at root level but are.', 'Fix manually by moving record into page tree', 2),
-                               'misplaced_inside_tree' => array('Records that should be at root level but are not.', 'Fix manually by moving record to tree root', 2),
-                               '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)
-                       ),
-                       'orphans' => array(),
-                       'misplaced_at_rootlevel' => array(),
-                       // Subset of "all": Those that should not be at root level but are. [Warning: Fix by moving record into page tree]
-                       'misplaced_inside_tree' => array(),
-                       // Subset of "all": Those that are inside page tree but should be at root level [Warning: Fix by setting PID to zero]
-                       'illegal_record_under_versioned_page' => array()
-               );
-               // zero = tree root, must use tree root if you wish to reverse selection to find orphans!
-               $startingPoint = 0;
-               $pt = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
-               $this->genTree($startingPoint, 1000, (int) $this->cli_argValue('--echotree'));
-               $resultArray['misplaced_at_rootlevel'] = $this->recStats['misplaced_at_rootlevel'];
-               $resultArray['misplaced_inside_tree'] = $this->recStats['misplaced_inside_tree'];
-               $resultArray['illegal_record_under_versioned_page'] = $this->recStats['illegal_record_under_versioned_page'];
-               // Find orphans:
-               foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
-                       $idList = is_array($this->recStats['all'][$tableName]) && count($this->recStats['all'][$tableName]) ? implode(',', $this->recStats['all'][$tableName]) : 0;
-                       // Select all records belonging to page:
-                       $orphanRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $tableName, 'uid NOT IN (' . $idList . ')', '', 'uid', '', 'uid');
-                       if (count($orphanRecords)) {
-                               $resultArray['orphans'][$tableName] = array();
-                               foreach ($orphanRecords as $oR) {
-                                       $resultArray['orphans'][$tableName][$oR['uid']] = $oR['uid'];
-                               }
-                       }
-               }
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               // Putting "pages" table in the bottom:
-               if (isset($resultArray['orphans']['pages'])) {
-                       $_pages = $resultArray['orphans']['pages'];
-                       unset($resultArray['orphans']['pages']);
-                       $resultArray['orphans']['pages'] = $_pages;
-               }
-               // Traversing records:
-               foreach ($resultArray['orphans'] as $table => $list) {
-                       echo 'Removing orphans from table "' . $table . '":' . LF;
-                       foreach ($list as $uid) {
-                               echo '  Flushing orphan record "' . $table . ':' . $uid . '": ';
-                               if ($bypass = $this->cli_noExecutionCheck($table . ':' . $uid)) {
-                                       echo $bypass;
-                               } else {
-                                       // Execute CMD array:
-                                       $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
-                                       $tce->stripslashes_values = FALSE;
-                                       $tce->start(array(), array());
-                                       // Notice, we are deleting pages with no regard to subpages/subrecords - we do this
-                                       // since they should also be included in the set of orphans of course!
-                                       $tce->deleteRecord($table, $uid, TRUE, TRUE);
-                                       // Return errors if any:
-                                       if (count($tce->errorLog)) {
-                                               echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
-                                       } else {
-                                               echo 'DONE';
-                                       }
-                               }
-                               echo LF;
-                       }
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/RteImagesCommand.php b/typo3/sysext/integrity/Classes/RteImagesCommand.php
deleted file mode 100644 (file)
index e935c92..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: RTE magicc images
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for RTE images integrity
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class RteImagesCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * @todo Define visibility
-        */
-       public $checkRefIndex = TRUE;
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $this->cli_help['name'] = 'rte_images -- Looking up all occurencies of RTEmagic images in the database and check existence of parent and copy files on the file system plus report possibly lost files of this type.';
-               $this->cli_help['description'] = trim('
-Assumptions:
-- a perfect integrity of the reference index table (always update the reference index table before using this tool!)
-- that all RTEmagic image files in the database are registered with the soft reference parser "images"
-- images found in deleted records are included (means that you might find lost RTEmagic images after flushing deleted records)
-
-The assumptions are not requirements by the TYPO3 API but reflects the de facto implementation of most TYPO3 installations.
-However, many custom fields using an RTE will probably not have the "images" soft reference parser registered and so the index will be incomplete and not listing all RTEmagic image files.
-The consequence of this limitation is that you should be careful if you wish to delete lost RTEmagic images - they could be referenced from a field not parsed by the "images" soft reference parser!
-
-Automatic Repair of Errors:
-- Will search for double-usages of RTEmagic images and make copies as required.
-- Lost files can be deleted automatically by setting the value "lostFiles" as an optional parameter to --AUTOFIX, but otherwise delete them manually if you do not recognize them as used somewhere the system does not know about.
-
-Manual repair suggestions:
-- Missing files: Re-insert missing files or edit record where the reference is found.
-');
-               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner rte_images -s -r
-Reports problems with RTE images';
-       }
-
-       /**
-        * Analyse situation with RTE magic images. (still to define what the most useful output is).
-        * Fix methods: API in t3lib_refindex that allows to change the value of a reference (we could copy the files) or remove reference
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'completeFileList' => array('Complete list of used RTEmagic files', 'Both parent and copy are listed here including usage count (which should in theory all be "1"). This list does not exclude files that might be missing.', 1),
-                               'RTEmagicFilePairs' => array('Statistical info about RTEmagic files', '(copy used as index)', 0),
-                               'doubleFiles' => array('Duplicate RTEmagic image files', 'These files are RTEmagic images found used in multiple records! RTEmagic images should be used by only one record at a time. A large amount of such images probably stems from previous versions of TYPO3 (before 4.2) which did not support making copies automatically of RTEmagic images in case of new copies / versions.', 3),
-                               'missingFiles' => array('Missing RTEmagic image files', 'These files are not found in the file system! Should be corrected!', 3),
-                               'lostFiles' => array('Lost RTEmagic files from uploads/', 'These files you might be able to delete but only if _all_ RTEmagic images are found by the soft reference parser. If you are using the RTE in third-party extensions it is likely that the soft reference parser is not applied correctly to their RTE and thus these "lost" files actually represent valid RTEmagic images, just not registered. Lost files can be auto-fixed but only if you specifically set "lostFiles" as parameter to the --AUTOFIX option.', 2)
-                       ),
-                       'RTEmagicFilePairs' => array(),
-                       'doubleFiles' => array(),
-                       'completeFileList' => array(),
-                       'missingFiles' => array(),
-                       'lostFiles' => array()
-               );
-               // Select all RTEmagic files in the reference table (only from soft references of course)
-               $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string LIKE ' . $TYPO3_DB->fullQuoteStr('%/RTEmagic%', 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('images', 'sys_refindex'), '', 'sorting DESC');
-               // Traverse the files and put into a large table:
-               if (is_array($recs)) {
-                       foreach ($recs as $rec) {
-                               $filename = basename($rec['ref_string']);
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($filename, 'RTEmagicC_')) {
-                                       $original = 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
-                                       $infoString = $this->infoStr($rec);
-                                       // Build index:
-                                       $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['exists'] = @is_file((PATH_site . $rec['ref_string']));
-                                       $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original'] = substr($rec['ref_string'], 0, -strlen($filename)) . $original;
-                                       $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original_exists'] = @is_file((PATH_site . $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original']));
-                                       $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['count']++;
-                                       $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['usedIn'][$rec['hash']] = $infoString;
-                                       $resultArray['completeFileList'][$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original']]++;
-                                       $resultArray['completeFileList'][$rec['ref_string']]++;
-                                       // Missing files:
-                                       if (!$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['exists']) {
-                                               $resultArray['missingFiles'][$rec['ref_string']] = $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['usedIn'];
-                                       }
-                                       if (!$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original_exists']) {
-                                               $resultArray['missingFiles'][$resultArray['RTEmagicFilePairs'][$rec['ref_string']]['original']] = $resultArray['RTEmagicFilePairs'][$rec['ref_string']]['usedIn'];
-                                       }
-                               }
-                       }
-                       // Searching for duplicates:
-                       foreach ($resultArray['RTEmagicFilePairs'] as $fileName => $fileInfo) {
-                               if ($fileInfo['count'] > 1 && $fileInfo['exists'] && $fileInfo['original_exists']) {
-                                       $resultArray['doubleFiles'][$fileName] = $fileInfo['usedIn'];
-                               }
-                       }
-               }
-               // Now, ask for RTEmagic files inside uploads/ folder:
-               $cleanerModules = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lowlevel']['cleanerModules'];
-               $cleanerMode = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($cleanerModules['lost_files'][0]);
-               $resLostFiles = $cleanerMode->main(array(), FALSE, TRUE);
-               if (is_array($resLostFiles['RTEmagicFiles'])) {
-                       foreach ($resLostFiles['RTEmagicFiles'] as $fileName) {
-                               if (!isset($resultArray['completeFileList'][$fileName])) {
-                                       $resultArray['lostFiles'][$fileName] = $fileName;
-                               }
-                       }
-               }
-               ksort($resultArray['RTEmagicFilePairs']);
-               ksort($resultArray['completeFileList']);
-               ksort($resultArray['missingFiles']);
-               ksort($resultArray['doubleFiles']);
-               ksort($resultArray['lostFiles']);
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               $limitTo = $this->cli_args['--AUTOFIX'][0];
-               if (is_array($resultArray['doubleFiles'])) {
-                       if (!$limitTo || $limitTo === 'doubleFiles') {
-                               echo 'FIXING double-usages of RTE files in uploads/: ' . LF;
-                               foreach ($resultArray['RTEmagicFilePairs'] as $fileName => $fileInfo) {
-                                       // Only fix something if there is a usage count of more than 1 plus if both original and copy exists:
-                                       if ($fileInfo['count'] > 1 && $fileInfo['exists'] && $fileInfo['original_exists']) {
-                                               // Traverse all records using the file:
-                                               $c = 0;
-                                               foreach ($fileInfo['usedIn'] as $hash => $recordID) {
-                                                       if ($c == 0) {
-                                                               echo '  Keeping file ' . $fileName . ' for record ' . $recordID . LF;
-                                                       } else {
-                                                               // CODE below is adapted from "class.tx_impexp.php" where there is support for duplication of RTE images:
-                                                               echo '  Copying file ' . basename($fileName) . ' for record ' . $recordID . ' ';
-                                                               // Initialize; Get directory prefix for file and set the original name:
-                                                               $dirPrefix = dirname($fileName) . '/';
-                                                               $rteOrigName = basename($fileInfo['original']);
-                                                               // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
-                                                               if ($rteOrigName && \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir((PATH_site . $dirPrefix))) {
-                                                                       // RTE:
-                                                                       // From the "original" RTE filename, produce a new "original" destination filename which is unused.
-                                                                       $fileProcObj = $this->getFileProcObj();
-                                                                       $origDestName = $fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
-                                                                       // Create copy file name:
-                                                                       $pI = pathinfo($fileName);
-                                                                       $copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
-                                                                       if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($origDestName) && $copyDestName === \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($copyDestName)) {
-                                                                               echo ' to ' . basename($copyDestName);
-                                                                               if ($bypass = $this->cli_noExecutionCheck($fileName)) {
-                                                                                       echo $bypass;
-                                                                               } else {
-                                                                                       // Making copies:
-                                                                                       \TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
-                                                                                       \TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move(PATH_site . $fileName, $copyDestName);
-                                                                                       clearstatcache();
-                                                                                       if (@is_file($copyDestName)) {
-                                                                                               $sysRefObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                                                                                               $error = $sysRefObj->setReferenceValue($hash, substr($copyDestName, strlen(PATH_site)));
-                                                                                               if ($error) {
-                                                                                                       echo '  - ERROR:        TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error . LF;
-                                                                                                       die;
-                                                                                               } else {
-                                                                                                       echo ' - DONE';
-                                                                                               }
-                                                                                       } else {
-                                                                                               echo '  - ERROR: File "' . $copyDestName . '" was not created!';
-                                                                                       }
-                                                                               }
-                                                                       } else {
-                                                                               echo '  - ERROR: Could not construct new unique names for file!';
-                                                                       }
-                                                               } else {
-                                                                       echo '  - ERROR: Maybe directory of file was not within "uploads/"?';
-                                                               }
-                                                               echo LF;
-                                                       }
-                                                       $c++;
-                                               }
-                                       }
-                               }
-                       } else {
-                               echo 'Bypassing fixing of double-usages since --AUTOFIX was not "doubleFiles"' . LF;
-                       }
-               }
-               if (is_array($resultArray['lostFiles'])) {
-                       if ($limitTo === 'lostFiles') {
-                               echo 'Removing lost RTEmagic files from folders inside uploads/: ' . LF;
-                               foreach ($resultArray['lostFiles'] as $key => $value) {
-                                       $absFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($value);
-                                       echo 'Deleting file: "' . $absFileName . '": ';
-                                       if ($bypass = $this->cli_noExecutionCheck($absFileName)) {
-                                               echo $bypass;
-                                       } else {
-                                               if ($absFileName && @is_file($absFileName)) {
-                                                       unlink($absFileName);
-                                                       echo 'DONE';
-                                               } else {
-                                                       echo '  ERROR: File "' . $absFileName . '" was not found!';
-                                               }
-                                       }
-                                       echo LF;
-                               }
-                       }
-               } else {
-                       echo 'Bypassing fixing of double-usages since --AUTOFIX was not "lostFiles"' . LF;
-               }
-       }
-
-       /**
-        * Returns file processing object, initialized only once.
-        *
-        * @return object File processor object
-        * @todo Define visibility
-        */
-       public function getFileProcObj() {
-               if (!is_object($this->fileProcObj)) {
-                       $this->fileProcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtility');
-                       $this->fileProcObj->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
-                       $this->fileProcObj->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
-               }
-               return $this->fileProcObj;
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/SyslogCommand.php b/typo3/sysext/integrity/Classes/SyslogCommand.php
deleted file mode 100644 (file)
index 423b7ea..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2007-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: syslog
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * syslog
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class SyslogCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               $this->cli_help['name'] = 'syslog -- Show entries from syslog';
-               $this->cli_help['description'] = trim('
-Showing last 25 hour entries from the syslog. More features pending. This is the most basic and can be useful for nightly check test reports.
-');
-               $this->cli_help['examples'] = '';
-       }
-
-       /**
-        * Find syslog
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'listing' => array('', '', 1),
-                               'allDetails' => array('', '', 0)
-                       ),
-                       'listing' => array(),
-                       'allDetails' => array()
-               );
-               $rows = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_log', 'tstamp>' . ($GLOBALS['EXEC_TIME'] - 25 * 3600));
-               foreach ($rows as $r) {
-                       $l = unserialize($r['log_data']);
-                       $explained = '#' . $r['uid'] . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($r['tstamp']) . ' USER[' . $r['userid'] . ']: ' . sprintf($r['details'], $l[0], $l[1], $l[2], $l[3], $l[4], $l[5]);
-                       $resultArray['listing'][$r['uid']] = $explained;
-                       $resultArray['allDetails'][$r['uid']] = array($explained, \TYPO3\CMS\Core\Utility\GeneralUtility::arrayToLogString($r, 'uid,userid,action,recuid,tablename,recpid,error,tstamp,type,details_nr,IP,event_pid,NEWid,workspace'));
-               }
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/Utility/ArrayBrowser.php b/typo3/sysext/integrity/Classes/Utility/ArrayBrowser.php
deleted file mode 100644 (file)
index 7b10c96..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity\Utility;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Class for displaying an array as a tree
- *
- * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
- * XHTML compliant
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Class for displaying an array as a tree
- * See the extension 'lowlevel' /config (Backend module 'Tools > Configuration')
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage t3lib
- * @see SC_mod_tools_config_index::main()
- */
-class ArrayBrowser {
-
-       /**
-        * @todo Define visibility
-        */
-       public $expAll = FALSE;
-
-       // If set, will expand all (depthKeys is obsolete then) (and no links are applied)
-       /**
-        * @todo Define visibility
-        */
-       public $dontLinkVar = FALSE;
-
-       // If set, the variable keys are not linked.
-       /**
-        * @todo Define visibility
-        */
-       public $depthKeys = array();
-
-       // Array defining which keys to expand. Typically set from outside from some session variable - otherwise the array will collapse.
-       /**
-        * @todo Define visibility
-        */
-       public $searchKeys = array();
-
-       // After calling the getSearchKeys function this array is populated with the key-positions in the array which contains values matching the search.
-       /**
-        * @todo Define visibility
-        */
-       public $fixedLgd = 1;
-
-       // If set, the values are truncated with "..." appended if longer than a certain length.
-       /**
-        * @todo Define visibility
-        */
-       public $regexMode = 0;
-
-       // If set, search for string with regex, otherwise stristr()
-       /**
-        * @todo Define visibility
-        */
-       public $searchKeysToo = FALSE;
-
-       // If set, array keys are subject to the search too.
-       /**
-        * @todo Define visibility
-        */
-       public $varName = '';
-
-       // Set var name here if you want links to the variable name.
-       /**
-        * Make browsable tree
-        * Before calling this function you may want to set some of the internal vars like depthKeys, regexMode and fixedLgd.
-        * For examples see SC_mod_tools_config_index::main()
-        *
-        * @param array $arr The array to display
-        * @param string $depth_in Key-position id. Build up during recursive calls - [key1].[key2].[key3] - an so on.
-        * @param string $depthData Depth-data - basically a prefix for the icons. For calling this function from outside, let it stay blank.
-        * @return string HTML for the tree
-        * @see SC_mod_tools_config_index::main()
-        * @todo Define visibility
-        */
-       public function tree($arr, $depth_in, $depthData) {
-               $HTML = '';
-               $a = 0;
-               if ($depth_in) {
-                       $depth_in = $depth_in . '.';
-               }
-               $c = count($arr);
-               foreach ($arr as $key => $value) {
-                       $a++;
-                       $depth = $depth_in . $key;
-                       $goto = 'a' . substr(md5($depth), 0, 6);
-                       if (is_object($arr[$key])) {
-                               $arr[$key] = (array) $arr[$key];
-                       }
-                       $isArray = is_array($arr[$key]);
-                       $deeper = $isArray && ($this->depthKeys[$depth] || $this->expAll);
-                       $PM = 'join';
-                       $LN = $a == $c ? 'blank' : 'line';
-                       $BTM = $a == $c ? 'bottom' : '';
-                       $PM = $isArray ? ($deeper ? 'minus' : 'plus') : 'join';
-                       $HTML .= $depthData;
-                       $theIcon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/' . $PM . $BTM . '.gif'), 'width="18" height="16"') . ' align="top" border="0" alt="" />';
-                       if ($PM == 'join') {
-                               $HTML .= $theIcon;
-                       } else {
-                               $HTML .= ($this->expAll ? '' : '<a id="' . $goto . '" href="' . htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M')) . '&node[' . $depth . ']=' . ($deeper ? 0 : 1) . '#' . $goto)) . '">') . $theIcon . ($this->expAll ? '' : '</a>');
-                       }
-                       $label = $key;
-                       $HTML .= $this->wrapArrayKey($label, $depth, !$isArray ? $arr[$key] : '');
-                       if (!$isArray) {
-                               $theValue = $arr[$key];
-                               if ($this->fixedLgd) {
-                                       $imgBlocks = ceil(1 + strlen($depthData) / 77);
-                                       $lgdChars = 68 - ceil(strlen(('[' . $key . ']')) * 0.8) - $imgBlocks * 3;
-                                       $theValue = $this->fixed_lgd($theValue, $lgdChars);
-                               }
-                               if ($this->searchKeys[$depth]) {
-                                       $HTML .= '=<span style="color:red;">' . $this->wrapValue($theValue, $depth) . '</span>';
-                               } else {
-                                       $HTML .= '=' . $this->wrapValue($theValue, $depth);
-                               }
-                       }
-                       $HTML .= '<br />';
-                       if ($deeper) {
-                               $HTML .= $this->tree($arr[$key], $depth, $depthData . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/' . $LN . '.gif'), 'width="18" height="16"') . ' align="top" alt="" />');
-                       }
-               }
-               return $HTML;
-       }
-
-       /**
-        * Wrapping the value in bold tags etc.
-        *
-        * @param string $theValue The title string
-        * @param string $depth Depth path
-        * @return string Title string, htmlspecialchars()'ed
-        * @todo Define visibility
-        */
-       public function wrapValue($theValue, $depth) {
-               $wrappedValue = '';
-               if (strlen($theValue) > 0) {
-                       $wrappedValue = '<strong>' . htmlspecialchars($theValue) . '</strong>';
-               }
-               return $wrappedValue;
-       }
-
-       /**
-        * Wrapping the value in bold tags etc.
-        *
-        * @param string $label The title string
-        * @param string $depth Depth path
-        * @param string $theValue The value for the array entry.
-        * @return string Title string, htmlspecialchars()'ed
-        * @todo Define visibility
-        */
-       public function wrapArrayKey($label, $depth, $theValue) {
-               // Protect label:
-               $label = htmlspecialchars($label);
-               // If varname is set:
-               if ($this->varName && !$this->dontLinkVar) {
-                       $variableName = $this->varName . '[\'' . str_replace('.', '\'][\'', $depth) . '\'] = ' . (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theValue) ? '\'' . addslashes($theValue) . '\'' : $theValue) . '; ';
-                       $label = '<a href="' . htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M')) . '&varname=' . urlencode($variableName))) . '#varname">' . $label . '</a>';
-               }
-               // Return:
-               return '[' . $label . ']';
-       }
-
-       /**
-        * Creates an array with "depthKeys" which will expand the array to show the search results
-        *
-        * @param array $keyArr The array to search for the value
-        * @param string $depth_in Depth string - blank for first call (will build up during recursive calling creating an id of the position: [key1].[key2].[key3]
-        * @param string $searchString The string to search for
-        * @param array $keyArray Key array, for first call pass empty array
-        * @return array
-        * @todo Define visibility
-        */
-       public function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray) {
-               $c = count($keyArr);
-               if ($depth_in) {
-                       $depth_in = $depth_in . '.';
-               }
-               foreach ($keyArr as $key => $value) {
-                       $depth = $depth_in . $key;
-                       $deeper = is_array($keyArr[$key]);
-                       if ($this->regexMode) {
-                               if (preg_match('/' . $searchString . '/', $keyArr[$key]) || $this->searchKeysToo && preg_match('/' . $searchString . '/', $key)) {
-                                       $this->searchKeys[$depth] = 1;
-                               }
-                       } else {
-                               if (!$deeper && stristr($keyArr[$key], $searchString) || $this->searchKeysToo && stristr($key, $searchString)) {
-                                       $this->searchKeys[$depth] = 1;
-                               }
-                       }
-                       if ($deeper) {
-                               $cS = count($this->searchKeys);
-                               $keyArray = $this->getSearchKeys($keyArr[$key], $depth, $searchString, $keyArray);
-                               if ($cS != count($this->searchKeys)) {
-                                       $keyArray[$depth] = 1;
-                               }
-                       }
-               }
-               return $keyArray;
-       }
-
-       /**
-        * Fixed length function
-        *
-        * @param string $string String to process
-        * @param integer $chars Max number of chars
-        * @return string Processed string
-        * @todo Define visibility
-        */
-       public function fixed_lgd($string, $chars) {
-               if ($chars >= 4) {
-                       if (strlen($string) > $chars) {
-                               return substr($string, 0, ($chars - 3)) . '...';
-                       }
-               }
-               return $string;
-       }
-
-       /**
-        * Function modifying the depthKey array
-        *
-        * @param array $arr Array with instructions to open/close nodes.
-        * @param array $settings Input depth_key array
-        * @return array Output depth_key array with entries added/removed based on $arr
-        * @see SC_mod_tools_config_index::main()
-        * @todo Define visibility
-        */
-       public function depthKeys($arr, $settings) {
-               $tsbrArray = array();
-               foreach ($arr as $theK => $theV) {
-                       $theKeyParts = explode('.', $theK);
-                       $depth = '';
-                       $c = count($theKeyParts);
-                       $a = 0;
-                       foreach ($theKeyParts as $p) {
-                               $a++;
-                               $depth .= ($depth ? '.' : '') . $p;
-                               $tsbrArray[$depth] = $c == $a ? $theV : 1;
-                       }
-               }
-               // Modify settings
-               foreach ($tsbrArray as $theK => $theV) {
-                       if ($theV) {
-                               $settings[$theK] = 1;
-                       } else {
-                               unset($settings[$theK]);
-                       }
-               }
-               return $settings;
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/VersionsCommand.php b/typo3/sysext/integrity/Classes/VersionsCommand.php
deleted file mode 100644 (file)
index b8b43cf..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-/**
- * Cleaner module: Versions of records
- * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Looking for versions of records
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class VersionsCommand extends \TYPO3\CMS\Integrity\CleanerCommand {
-
-       /**
-        * Constructor
-        *
-        * @todo Define visibility
-        */
-       public function __construct() {
-               parent::__construct();
-               // Setting up help:
-               $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.');
-               $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
-               $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.');
-               $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)');
-               $this->cli_help['name'] = 'versions -- To find information about versions and workspaces in the system';
-               $this->cli_help['description'] = trim('
-Traversing page tree and finding versions, categorizing them by various properties.
-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.
-
-Automatic Repair:
-- Deleting (completely) published versions from LIVE workspace OR _all_ offline versions from Live workspace (toogle by --flush-live)
-- 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)
-- Deleting unused placeholders
-');
-               $this->cli_help['examples'] = '';
-       }
-
-       /**
-        * Find orphan records
-        * VERY CPU and memory intensive since it will look up the whole page tree!
-        *
-        * @return array
-        * @todo Define visibility
-        */
-       public function main() {
-               global $TYPO3_DB;
-               // Initialize result array:
-               $resultArray = array(
-                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
-                       'headers' => array(
-                               'versions' => array('All versions', 'Showing all versions of records found', 0),
-                               'versions_published' => array('All published versions', 'This is all records that has been published and can therefore be removed permanently', 1),
-                               '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),
-                               'versions_lost_workspace' => array('Versions outside a workspace', 'Versions that has lost their connection to a workspace in TYPO3.', 3),
-                               '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),
-                               'versions_unused_placeholders' => array('Unused placeholder records', 'Placeholder records which are not used anymore by offline versions.', 2),
-                               'versions_move_placeholders_ok' => array('Move placeholders', 'Move-to placeholder records which has good integrity', 0),
-                               'versions_move_placeholders_bad' => array('Move placeholders with bad integrity', 'Move-to placeholder records which has bad integrity', 2),
-                               '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)
-                       ),
-                       'versions' => array()
-               );
-               $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
-               $depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
-               $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'));
-               $resultArray['versions'] = $this->recStats['versions'];
-               $resultArray['versions_published'] = $this->recStats['versions_published'];
-               $resultArray['versions_liveWS'] = $this->recStats['versions_liveWS'];
-               $resultArray['versions_lost_workspace'] = $this->recStats['versions_lost_workspace'];
-               $resultArray['versions_inside_versioned_page'] = $this->recStats['versions_inside_versioned_page'];
-               // Finding all placeholders with no records attached!
-               $resultArray['versions_unused_placeholders'] = array();
-               foreach ($GLOBALS['TCA'] as $table => $cfg) {
-                       if ($cfg['ctrl']['versioningWS']) {
-                               $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid', $table, 't3ver_state=1 AND pid>=0' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table));
-                               foreach ($placeHolders as $phrec) {
-                                       if (count(\TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord($table, $phrec['uid'], 'uid')) <= 1) {
-                                               $resultArray['versions_unused_placeholders'][\TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($table . ':' . $phrec['uid'])] = $table . ':' . $phrec['uid'];
-                                       }
-                               }
-                       }
-               }
-               asort($resultArray['versions_unused_placeholders']);
-               // Finding all move placeholders with inconsistencies:
-               $resultArray['versions_move_placeholders_ok'] = array();
-               $resultArray['versions_move_placeholders_bad'] = array();
-               foreach ($GLOBALS['TCA'] as $table => $cfg) {
-                       if ((int) $cfg['ctrl']['versioningWS'] >= 2) {
-                               $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state', $table, 't3ver_state=3 AND pid>=0' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table));
-                               foreach ($placeHolders as $phrec) {
-                                       $shortID = \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($table . ':' . $phrec['uid']);
-                                       if ((int) $phrec['t3ver_wsid'] != 0) {
-                                               $phrecCopy = $phrec;
-                                               if (\TYPO3\CMS\Backend\Utility\BackendUtility::movePlhOL($table, $phrec)) {
-                                                       if ($wsAlt = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($phrecCopy['t3ver_wsid'], $table, $phrec['uid'], 'uid,pid,t3ver_state')) {
-                                                               if ($wsAlt['t3ver_state'] != 4) {
-                                                                       $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'State for version was not "4" as it should be!', $phrecCopy);
-                                                               } else {
-                                                                       $resultArray['versions_move_placeholders_ok'][$shortID] = array(
-                                                                               $table . ':' . $phrec['uid'],
-                                                                               'PLH' => $phrecCopy,
-                                                                               'online' => $phrec,
-                                                                               'PNT' => $wsAlt
-                                                                       );
-                                                               }
-                                                       } else {
-                                                               $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);
-                                                       }
-                                               } else {
-                                                       $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);
-                                               }
-                                       } else {
-                                               $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'Placeholder was not assigned a workspace value in t3ver_wsid.', $phrec);
-                                       }
-                               }
-                       }
-               }
-               ksort($resultArray['versions_move_placeholders_ok']);
-               ksort($resultArray['versions_move_placeholders_bad']);
-               // Finding move_id_check inconsistencies:
-               $resultArray['versions_move_id_check'] = array();
-               foreach ($GLOBALS['TCA'] as $table => $cfg) {
-                       if ((int) $cfg['ctrl']['versioningWS'] >= 2) {
-                               $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state', $table, 't3ver_move_id<>0' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table));
-                               foreach ($placeHolders as $phrec) {
-                                       if ((int) $phrec['t3ver_state'] == 3) {
-                                               if ($phrec['pid'] != -1) {
-
-                                               } else {
-                                                       $resultArray['versions_move_id_check'][] = array($table . ':' . $phrec['uid'], 'Record was offline, must not be!', $phrec);
-                                               }
-                                       } else {
-                                               $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);
-                                       }
-                               }
-                       }
-               }
-               return $resultArray;
-       }
-
-       /**
-        * Mandatory autofix function
-        * Will run auto-fix on the result array. Echos status during processing.
-        *
-        * @param array $resultArray Result array from main() function
-        * @return void
-        * @todo Define visibility
-        */
-       public function main_autoFix($resultArray) {
-               $kk = $this->cli_isArg('--flush-live') ? 'versions_liveWS' : 'versions_published';
-               // Putting "pages" table in the bottom:
-               if (isset($resultArray[$kk]['pages'])) {
-                       $_pages = $resultArray[$kk]['pages'];
-                       unset($resultArray[$kk]['pages']);
-                       $resultArray[$kk]['pages'] = $_pages;
-               }
-               // Traversing records:
-               foreach ($resultArray[$kk] as $table => $list) {
-                       echo 'Flushing published records from table "' . $table . '":' . LF;
-                       foreach ($list as $uid) {
-                               echo '  Flushing record "' . $table . ':' . $uid . '": ';
-                               if ($bypass = $this->cli_noExecutionCheck($table . ':' . $uid)) {
-                                       echo $bypass;
-                               } else {
-                                       // Execute CMD array:
-                                       $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
-                                       $tce->stripslashes_values = FALSE;
-                                       $tce->start(array(), array());
-                                       $tce->deleteEl($table, $uid, TRUE, TRUE);
-                                       // Return errors if any:
-                                       if (count($tce->errorLog)) {
-                                               echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
-                                       } else {
-                                               echo 'DONE';
-                                       }
-                               }
-                               echo LF;
-                       }
-               }
-               // Traverse workspace:
-               foreach ($resultArray['versions_lost_workspace'] as $table => $list) {
-                       echo 'Resetting workspace to zero for records from table "' . $table . '":' . LF;
-                       foreach ($list as $uid) {
-                               echo '  Flushing record "' . $table . ':' . $uid . '": ';
-                               if ($bypass = $this->cli_noExecutionCheck($table . ':' . $uid)) {
-                                       echo $bypass;
-                               } else {
-                                       $fields_values = array(
-                                               't3ver_wsid' => 0
-                                       );
-                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($uid), $fields_values);
-                                       echo 'DONE';
-                               }
-                               echo LF;
-                       }
-               }
-               // Delete unused placeholders
-               foreach ($resultArray['versions_unused_placeholders'] as $recID) {
-                       list($table, $uid) = explode(':', $recID);
-                       echo 'Deleting unused placeholder (soft) "' . $table . ':' . $uid . '": ';
-                       if ($bypass = $this->cli_noExecutionCheck($table . ':' . $uid)) {
-                               echo $bypass;
-                       } else {
-                               // Execute CMD array:
-                               $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
-                               $tce->stripslashes_values = FALSE;
-                               $tce->start(array(), array());
-                               $tce->deleteAction($table, $uid);
-                               // Return errors if any:
-                               if (count($tce->errorLog)) {
-                                       echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
-                               } else {
-                                       echo 'DONE';
-                               }
-                       }
-                       echo LF;
-               }
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/View/ConfigurationView.php b/typo3/sysext/integrity/Classes/View/ConfigurationView.php
deleted file mode 100644 (file)
index 0c60794..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity\View;
-
-/**
- * Script class for the Config module
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class ConfigurationView {
-
-       /**
-        * @todo Define visibility
-        */
-       public $MCONF = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $MOD_MENU = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $MOD_SETTINGS = array();
-
-       /**
-        * Document template object
-        *
-        * @var \TYPO3\CMS\Backend\Template\StandardDocumentTemplate
-        * @todo Define visibility
-        */
-       public $doc;
-
-       /**
-        * @todo Define visibility
-        */
-       public $include_once = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $content;
-
-       /**
-        * Initialization
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function init() {
-               global $BACK_PATH;
-               $this->MCONF = $GLOBALS['MCONF'];
-               $this->menuConfig();
-               $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-               $this->doc->backPath = $BACK_PATH;
-               $this->doc->setModuleTemplate('templates/config.html');
-               // JavaScript
-               $this->doc->JScode = '
-               <script language="javascript" type="text/javascript">
-                       script_ended = 0;
-                       function jumpToUrl(URL) {
-                               window.location.href = URL;
-                       }
-               </script>
-               ';
-               $this->doc->form = '<form action="" method="post">';
-       }
-
-       /**
-        * Menu Configuration
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function menuConfig() {
-               global $TYPO3_CONF_VARS;
-               // MENU-ITEMS:
-               // If array, then it's a selector box menu
-               // If empty string it's just a variable, that'll be saved.
-               // Values NOT in this array will not be saved in the settings-array for the module.
-               $this->MOD_MENU = array(
-                       'function' => array(
-                               0 => $GLOBALS['LANG']->getLL('typo3ConfVars', TRUE),
-                               1 => $GLOBALS['LANG']->getLL('tca', TRUE),
-                               2 => $GLOBALS['LANG']->getLL('tcaDescr', TRUE),
-                               3 => $GLOBALS['LANG']->getLL('loadedExt', TRUE),
-                               4 => $GLOBALS['LANG']->getLL('t3services', TRUE),
-                               5 => $GLOBALS['LANG']->getLL('tbemodules', TRUE),
-                               6 => $GLOBALS['LANG']->getLL('tbemodulesext', TRUE),
-                               7 => $GLOBALS['LANG']->getLL('tbeStyles', TRUE),
-                               8 => $GLOBALS['LANG']->getLL('beUser', TRUE),
-                               9 => $GLOBALS['LANG']->getLL('usersettings', TRUE)
-                       ),
-                       'regexsearch' => '',
-                       'fixedLgd' => ''
-               );
-               // CLEANSE SETTINGS
-               $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $this->MCONF['name']);
-       }
-
-       /**
-        * [Describe function...]
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function main() {
-               $arrayBrowser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Integrity\\Utility\\ArrayBrowser');
-               $this->content = $this->doc->header($GLOBALS['LANG']->getLL('configuration', TRUE));
-               $this->content .= '<div id="lowlevel-config">
-                                               <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', TRUE) . '</label>
-                                               <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
-                                               <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', TRUE) . '" />';
-               $this->content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"') . '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', TRUE) . '</label>';
-               $this->content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') . '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label>
-                                               </div>';
-               $this->content .= $this->doc->spacer(5);
-               switch ($this->MOD_SETTINGS['function']) {
-               case 0:
-                       $theVar = $GLOBALS['TYPO3_CONF_VARS'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TYPO3_CONF_VARS';
-                       break;
-               case 1:
-                       foreach ($GLOBALS['TCA'] as $table => $config) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
-                       }
-                       $theVar = $GLOBALS['TCA'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TCA';
-                       break;
-               case 2:
-                       $theVar = $GLOBALS['TCA_DESCR'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TCA_DESCR';
-                       break;
-               case 3:
-                       $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
-                       break;
-               case 4:
-                       $theVar = $GLOBALS['T3_SERVICES'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$T3_SERVICES';
-                       break;
-               case 5:
-                       $theVar = $GLOBALS['TBE_MODULES'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TBE_MODULES';
-                       break;
-               case 6:
-                       $theVar = $GLOBALS['TBE_MODULES_EXT'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TBE_MODULES_EXT';
-                       break;
-               case 7:
-                       $theVar = $GLOBALS['TBE_STYLES'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TBE_STYLES';
-                       break;
-               case 8:
-                       $theVar = $GLOBALS['BE_USER']->uc;
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$BE_USER->uc';
-                       break;
-               case 9:
-                       $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar);
-                       $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
-                       break;
-               default:
-                       $theVar = array();
-                       break;
-               }
-               // Update node:
-               $update = 0;
-               $node = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('node');
-               // If any plus-signs were clicked, it's registred.
-               if (is_array($node)) {
-                       $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
-                       $update = 1;
-               }
-               if ($update) {
-                       $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'], $this->MOD_SETTINGS);
-               }
-               $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
-               $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
-               $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
-               $arrayBrowser->searchKeysToo = TRUE;
-               $search_field = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_field');
-               // If any POST-vars are send, update the condition array
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('search') && trim($search_field)) {
-                       $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
-               }
-               // mask the encryption key to not show it as plaintext in the configuration module
-               if ($theVar == $GLOBALS['TYPO3_CONF_VARS']) {
-                       $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)';
-               }
-               $tree = $arrayBrowser->tree($theVar, '', '');
-               $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
-               $this->content .= $this->doc->sectionEnd();
-               // Variable name:
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('varname')) {
-                       $line = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_') ? \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_') : \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('varname');
-                       // Write the line to extTables.php
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('writetoexttables')) {
-                               // change value to $GLOBALS
-                               $length = strpos($line, '[');
-                               $var = substr($line, 0, $length);
-                               $changedLine = '$GLOBALS[\'' . substr($line, 1, ($length - 1)) . '\']' . substr($line, $length);
-                               // load current extTables.php
-                               $extTables = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_typo3conf . TYPO3_extTableDef_script);
-                               if ($var === '$TCA') {
-                                       // check if we are editing the TCA
-                                       preg_match_all('/\\[\'([^\']+)\'\\]/', $line, $parts);
-                                       if ($parts[1][1] !== 'ctrl') {
-                                               // anything else than ctrl section requires to load TCA
-                                               $loadTCA = 'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA(\'' . $parts[1][0] . '\');';
-                                               if (strpos($extTables, $loadTCA) === FALSE) {
-                                                       // check if the loadTCA statement is not already present in the file
-                                                       $changedLine = $loadTCA . LF . $changedLine;
-                                               }
-                                       }
-                               }
-                               // insert line in extTables.php
-                               $extTables = preg_replace('/<\\?php|\\?>/is', '', $extTables);
-                               $extTables = '<?php' . (empty($extTables) ? LF : '') . $extTables . $changedLine . LF . '?>';
-                               $success = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
-                               if ($success) {
-                                       // show flash message
-                                       $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script, '<br />', '<strong>' . nl2br($changedLine) . '</strong>'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
-                               } else {
-                                       // Error: show flash message
-                                       $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
-                               }
-                               $this->content .= $flashMessage->render();
-                       }
-                       $this->content .= '<div id="lowlevel-config-var">
-                               <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
-                               <input type="text" name="_" value="' . trim(htmlspecialchars($line)) . '" size="120" /><br/>';
-                       if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
-                               // write only for $TCA and TBE_STYLES if  TYPO3_extTableDef_script is defined
-                               $this->content .= '<br /><input type="submit" name="writetoexttables" value="' . $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
-                       } else {
-                               $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
-                       }
-               }
-               $this->content .= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">';
-               $this->content .= '<tr>
-                                       <th class="t3-row-header t3-tree-config-header">' . $label . '</th>
-                               </tr>
-                               <tr>
-                                       <td>' . $tree . '</td>
-                               </tr>
-                       </table>
-               ';
-               // Setting up the buttons and markers for docheader
-               $docHeaderButtons = $this->getButtons();
-               $markers = array(
-                       'CSH' => $docHeaderButtons['csh'],
-                       'FUNC_MENU' => $this->getFuncMenu(),
-                       'CONTENT' => $this->content
-               );
-               // Build the <body> for the module
-               $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
-               // Renders the module page
-               $this->content = $this->doc->render('Configuration', $this->content);
-       }
-
-       /**
-        * Print output to browser
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function printContent() {
-               echo $this->content;
-       }
-
-       /**
-        * Create the panel of buttons for submitting the form or otherwise perform operations.
-        *
-        * @return array All available buttons as an assoc. array
-        */
-       protected function getButtons() {
-               $buttons = array(
-                       'csh' => '',
-                       'shortcut' => ''
-               );
-               // Shortcut
-               if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
-                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
-               }
-               return $buttons;
-       }
-
-       /**
-        * Create the function menu
-        *
-        * @return string HTML of the function menu
-        */
-       protected function getFuncMenu() {
-               $funcMenu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
-               return $funcMenu;
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Classes/View/DatabaseIntegrityView.php b/typo3/sysext/integrity/Classes/View/DatabaseIntegrityView.php
deleted file mode 100644 (file)
index 7562ca4..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity\View;
-
-/**
- * Script class for the DB int module
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage tx_lowlevel
- */
-class DatabaseIntegrityView {
-
-       /**
-        * @todo Define visibility
-        */
-       public $MCONF = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $MOD_MENU = array();
-
-       /**
-        * @todo Define visibility
-        */
-       public $MOD_SETTINGS = array();
-
-       /**
-        * Document template object
-        *
-        * @var \TYPO3\CMS\Backend\Template\MediumDocumentTemplate
-        * @todo Define visibility
-        */
-       public $doc;
-
-       /**
-        * @todo Define visibility
-        */
-       public $content;
-
-       /**
-        * @todo Define visibility
-        */
-       public $menu;
-
-       protected $formName = 'queryform';
-
-       /**
-        * Initialization
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function init() {
-               global $LANG, $BACK_PATH;
-               $this->MCONF = $GLOBALS['MCONF'];
-               $this->menuConfig();
-               $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-               $this->doc->backPath = $BACK_PATH;
-               $this->doc->setModuleTemplate('templates/dbint.html');
-               $this->doc->form = '<form action="" method="post" name="' . $this->formName . '">';
-               // JavaScript
-               $this->doc->JScode = '
-               <script language="javascript" type="text/javascript">
-                       script_ended = 0;
-                       function jumpToUrl(URL) {
-                               window.location.href = URL;
-                       }
-               </script>
-               ';
-               $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:400px!important;">
-                       <colgroup><col width="24"><col width="300"><col width="76"></colgroup>';
-               $this->doc->tableLayout = array(
-                       '0' => array(
-                               'defCol' => array('<td class="t3-row-header"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top" class="t3-row-header"><strong>', '</strong></td>')
-                       ),
-                       'defRow' => array(
-                               '0' => array('<td valign="top">', '</td>'),
-                               '1' => array('<td valign="top">', '</td>'),
-                               'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="15" height="1" alt="" /></td><td valign="top">', '</td>')
-                       )
-               );
-       }
-
-       /**
-        * Configure menu
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function menuConfig() {
-               global $LANG;
-               // MENU-ITEMS:
-               // If array, then it's a selector box menu
-               // If empty string it's just a variable, that'll be saved.
-               // Values NOT in this array will not be saved in the settings-array for the module.
-               $this->MOD_MENU = array(
-                       'function' => array(
-                               0 => $GLOBALS['LANG']->getLL('menu', TRUE),
-                               'records' => $GLOBALS['LANG']->getLL('recordStatistics', TRUE),
-                               'relations' => $GLOBALS['LANG']->getLL('databaseRelations', TRUE),
-                               'search' => $GLOBALS['LANG']->getLL('fullSearch', TRUE),
-                               'filesearch' => $GLOBALS['LANG']->getLL('findFilename', TRUE),
-                               'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', TRUE)
-                       ),
-                       'search' => array(
-                               'raw' => $GLOBALS['LANG']->getLL('rawSearch', TRUE),
-                               'query' => $GLOBALS['LANG']->getLL('advancedQuery', TRUE)
-                       ),
-                       'search_query_smallparts' => '',
-                       'search_result_labels' => '',
-                       'labels_noprefix' => '',
-                       'options_sortlabel' => '',
-                       'show_deleted' => '',
-                       'queryConfig' => '',
-                       // Current query
-                       'queryTable' => '',
-                       // Current table
-                       'queryFields' => '',
-                       // Current tableFields
-                       'queryLimit' => '',
-                       // Current limit
-                       'queryOrder' => '',
-                       // Current Order field
-                       'queryOrderDesc' => '',
-                       // Current Order field descending flag
-                       'queryOrder2' => '',
-                       // Current Order2 field
-                       'queryOrder2Desc' => '',
-                       // Current Order2 field descending flag
-                       'queryGroup' => '',
-                       // Current Group field
-                       'storeArray' => '',
-                       // Used to store the available Query config memory banks
-                       'storeQueryConfigs' => '',
-                       // Used to store the available Query configs in memory
-                       'search_query_makeQuery' => array(
-                               'all' => $GLOBALS['LANG']->getLL('selectRecords', TRUE),
-                               'count' => $GLOBALS['LANG']->getLL('countResults', TRUE),
-                               'explain' => $GLOBALS['LANG']->getLL('explainQuery', TRUE),
-                               'csv' => $GLOBALS['LANG']->getLL('csvExport', TRUE)
-                       ),
-                       'sword' => ''
-               );
-               // CLEAN SETTINGS
-               $OLD_MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, '', $this->MCONF['name'], 'ses');
-               $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $this->MCONF['name'], 'ses');
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('queryConfig')) {
-                       $qA = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('queryConfig');
-                       $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, array('queryConfig' => serialize($qA)), $this->MCONF['name'], 'ses');
-               }
-               $addConditionCheck = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qG_ins');
-               foreach ($OLD_MOD_SETTINGS as $key => $val) {
-                       if (substr($key, 0, 5) == 'query' && $this->MOD_SETTINGS[$key] != $val && $key != 'queryLimit' && $key != 'use_listview') {
-                               $setLimitToStart = 1;
-                               if ($key == 'queryTable' && !$addConditionCheck) {
-                                       $this->MOD_SETTINGS['queryConfig'] = '';
-                               }
-                       }
-                       if ($key == 'queryTable' && $this->MOD_SETTINGS[$key] != $val) {
-                               $this->MOD_SETTINGS['queryFields'] = '';
-                       }
-               }
-               if ($setLimitToStart) {
-                       $currentLimit = explode(',', $this->MOD_SETTINGS['queryLimit']);
-                       if ($currentLimit[1]) {
-                               $this->MOD_SETTINGS['queryLimit'] = '0,' . $currentLimit[1];
-                       } else {
-                               $this->MOD_SETTINGS['queryLimit'] = '0';
-                       }
-                       $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
-               }
-       }
-
-       /**
-        * Main
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function main() {
-               // Content creation
-               if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
-                       $this->menu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
-               }
-               switch ($this->MOD_SETTINGS['function']) {
-               case 'search':
-                       $this->func_search();
-                       break;
-               case 'records':
-                       $this->func_records();
-                       break;
-               case 'relations':
-                       $this->func_relations();
-                       break;
-               case 'filesearch':
-                       $this->func_filesearch();
-                       break;
-               case 'refindex':
-                       $this->func_refindex();
-                       break;
-               default:
-                       $this->func_default();
-                       break;
-               }
-               // Setting up the buttons and markers for docheader
-               $docHeaderButtons = $this->getButtons();
-               $markers = array(
-                       'CSH' => $docHeaderButtons['csh'],
-                       'FUNC_MENU' => $this->getFuncMenu(),
-                       'CONTENT' => $this->content
-               );
-               // Build the <body> for the module
-               $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
-               // Renders the module page
-               $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
-       }
-
-       /**
-        * Print content
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function printContent() {
-               echo $this->content;
-       }
-
-       /**
-        * Create the panel of buttons for submitting the form or otherwise perform operations.
-        *
-        * @return array All available buttons as an assoc. array
-        */
-       protected function getButtons() {
-               $buttons = array(
-                       'csh' => '',
-                       'shortcut' => ''
-               );
-               // Shortcut
-               if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
-                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function,search,search_query_makeQuery', $this->MCONF['name']);
-               }
-               return $buttons;
-       }
-
-       /**
-        * Create the function menu
-        *
-        * @return string HTML of the function menu
-        */
-       protected function getFuncMenu() {
-               if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
-                       $funcMenu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
-               }
-               return $funcMenu;
-       }
-
-       /**
-        * Creates the overview menu.
-        *
-        * @return void
-        */
-       protected function func_default() {
-               $availableModFuncs = array('records', 'relations', 'search', 'filesearch', 'refindex');
-               $content = '<dl class="t3-overview-list">';
-               foreach ($availableModFuncs as $modFunc) {
-                       $functionUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('tools_dbint') . '&SET[function]=' . $modFunc;
-                       $title = $GLOBALS['LANG']->getLL($modFunc);
-                       $description = $GLOBALS['LANG']->getLL($modFunc . '_description');
-                       $icon = '<img src="' . \t3lib_iconworks::skinImg($GLOBALS['BACK_PATH'], 'MOD:tools_dbint/db.gif', '', 1) . '" width="16" height="16" title="' . $title . '" alt="' . $title . '" />';
-                       $content .= '
-                               <dt><a href="' . htmlspecialchars($functionUrl) . '">' . $icon . $title . '</a></dt>
-                               <dd>' . $description . '</dd>
-                       ';
-               }
-               $content .= '</dl>';
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
-               $this->content .= $this->doc->section('', $content, FALSE, TRUE);
-       }
-
-       /****************************
-        *
-        * Functionality implementation
-        *
-        ****************************/
-       /**
-        * Check and update reference index!
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function func_refindex() {
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('manageRefIndex', TRUE));
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_update') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_check')) {
-                       $testOnly = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_check') ? TRUE : FALSE;
-                       // Call the functionality
-                       $refIndexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
-                       list($headerContent, $bodyContent) = $refIndexObj->updateIndex($testOnly);
-                       // Output content:
-                       $this->content .= $this->doc->section('', str_replace(LF, '<br/>', $bodyContent), FALSE, TRUE);
-               }
-               // Output content:
-               $content = '<p>' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p><br />';
-               $content .= '<input type="submit" name="_check" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonCheck') . '" /> <input type="submit" name="_update" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonUpdate') . '" /><br /><br />';
-               $this->content .= $this->doc->section('', $content, FALSE, TRUE);
-               // Command Line Interface
-               $content = '';
-               $content .= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
-               $content .= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h4>' . '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code><br />';
-               $content .= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h4>' . '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code><br /><br />';
-               $content .= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
-               $content .= '<p>' . $GLOBALS['LANG']->getLL('checkScript_moreDetails') . '<br /><a href="' . $GLOBALS['BACK_PATH'] . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt" target="_new">' . PATH_typo3 . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt</a></p>';
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('checkScript_headline'), $content, FALSE, TRUE);
-       }
-
-       /**
-        * Search (Full / Advanced)
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function func_search() {
-               global $LANG;
-               $fullsearch = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\QueryView');
-               $fullsearch->setFormName($this->formName);
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('search'));
-               $this->content .= $this->doc->spacer(5);
-               $menu2 = '';
-               if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
-                       $menu2 = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
-               }
-               if ($this->MOD_SETTINGS['search'] == 'query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
-               }
-               if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search'] == 'query') {
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts'], '', '', 'id="checkSearch_query_smallparts"') . '&nbsp;<label for="checkSearch_query_smallparts">' . $GLOBALS['LANG']->getLL('showSQL') . '</label><br />';
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels'], '', '', 'id="checkSearch_result_labels"') . '&nbsp;<label for="checkSearch_result_labels">' . $GLOBALS['LANG']->getLL('useFormattedStrings') . '</label><br />';
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'], '', '', 'id="checkLabels_noprefix"') . '&nbsp;<label for="checkLabels_noprefix">' . $GLOBALS['LANG']->getLL('dontUseOrigValues') . '</label><br />';
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel'], '', '', 'id="checkOptions_sortlabel"') . '&nbsp;<label for="checkOptions_sortlabel">' . $GLOBALS['LANG']->getLL('sortOptions') . '</label><br />';
-                       $menu2 .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted'], '', '', 'id="checkShow_deleted"') . '&nbsp;<label for="checkShow_deleted">' . $GLOBALS['LANG']->getLL('showDeleted') . '</label>';
-               }
-               $this->content .= $this->doc->section('', $menu2) . $this->doc->spacer(10);
-               switch ($this->MOD_SETTINGS['search']) {
-               case 'query':
-                       $this->content .= $fullsearch->queryMaker();
-                       break;
-               case 'raw':
-
-               default:
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), FALSE, TRUE);
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), FALSE, TRUE);
-                       break;
-               }
-       }
-
-       /**
-        * Records overview
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function func_records() {
-               /** @var $admin \TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck */
-               $admin = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
-               $admin->genTree_makeHTML = 0;
-               $admin->backPath = $GLOBALS['BACK_PATH'];
-               $admin->genTree(0, '');
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('records'));
-               // Pages stat
-               $codeArr = array();
-               $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
-               $i++;
-               $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array());
-               $codeArr[$i][] = $GLOBALS['LANG']->getLL('total_pages');
-               $codeArr[$i][] = count($admin->page_idArray);
-               $i++;
-               if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms')) {
-                       $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('hidden' => 1));
-                       $codeArr[$i][] = $GLOBALS['LANG']->getLL('hidden_pages');
-                       $codeArr[$i][] = $admin->recStats['hidden'];
-                       $i++;
-               }
-               $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('deleted' => 1));
-               $codeArr[$i][] = $GLOBALS['LANG']->getLL('deleted_pages');
-               $codeArr[$i][] = count($admin->recStats['deleted']['pages']);
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), FALSE, TRUE);
-               // Doktype
-               $codeArr = array();
-               $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
-               $doktype = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'];
-               if (is_array($doktype)) {
-                       foreach ($doktype as $n => $setup) {
-                               if ($setup[1] != '--div--') {
-                                       $codeArr[$n][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('doktype' => $setup[1]));
-                                       $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
-                                       $codeArr[$n][] = intval($admin->recStats['doktype'][$setup[1]]);
-                               }
-                       }
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), FALSE, TRUE);
-               }
-               // Tables and lost records
-               $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
-               $id_list = rtrim($id_list, ',');
-               $admin->lostRecords($id_list);
-               if ($admin->fixLostRecord(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fixLostRecords_table'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fixLostRecords_uid'))) {
-                       $admin = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
-                       $admin->backPath = $BACK_PATH;
-                       $admin->genTree(0, '');
-                       $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
-                       $id_list = rtrim($id_list, ',');
-                       $admin->lostRecords($id_list);
-               }
-               $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
-               $codeArr = array();
-               $codeArr['tableheader'] = array(
-                       $GLOBALS['LANG']->getLL('label'),
-                       $GLOBALS['LANG']->getLL('tablename'),
-                       $GLOBALS['LANG']->getLL('total_lost'),
-                       ''
-               );
-               $countArr = $admin->countRecords($id_list);
-               if (is_array($GLOBALS['TCA'])) {
-                       foreach ($GLOBALS['TCA'] as $t => $value) {
-                               if ($GLOBALS['TCA'][$t]['ctrl']['hideTable']) {
-                                       continue;
-                               }
-                               $codeArr[$t][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($t, array());
-                               $codeArr[$t][] = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$t]['ctrl']['title']);
-                               $codeArr[$t][] = $t;
-                               if ($t === 'pages' && $admin->lostPagesList !== '') {
-                                       $lostRecordCount = count(explode(',', $admin->lostPagesList));
-                               } else {
-                                       $lostRecordCount = count($admin->lRecords[$t]);
-                               }
-                               if ($countArr['all'][$t]) {
-                                       $theNumberOfRe = intval($countArr['non_deleted'][$t]) . '/' . $lostRecordCount;
-                               } else {
-                                       $theNumberOfRe = '';
-                               }
-                               $codeArr[$t][] = $theNumberOfRe;
-                               $lr = '';
-                               if (is_array($admin->lRecords[$t])) {
-                                       foreach ($admin->lRecords[$t] as $data) {
-                                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($admin->lostPagesList, $data[pid])) {
-                                                       $lr .= '<nobr><strong><a href="' . htmlspecialchars((\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('tools_dbint') . '&SET[function]=records&fixLostRecords_table=' . $t . '&fixLostRecords_uid=' . $data['uid'])) . '"><img src="' . $BACK_PATH . 'gfx/required_h.gif" width="10" hspace="3" height="10" border="0" align="top" title="' . $GLOBALS['LANG']->getLL('fixLostRecord') . '"></a>uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</strong></nobr><br>';
-                                               } else {
-                                                       $lr .= '<nobr><img src="' . $BACK_PATH . 'clear.gif" width="16" height="1" border="0"><font color="Gray">uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</font></nobr><br>';
-                                               }
-                                       }
-                               }
-                               $codeArr[$t][] = $lr;
-                       }
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), FALSE, TRUE);
-               }
-       }
-
-       /**
-        * Show list references
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function func_relations() {
-               global $LANG, $BACK_PATH;
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
-               $admin = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
-               $admin->genTree_makeHTML = 0;
-               $admin->backPath = $BACK_PATH;
-               $fkey_arrays = $admin->getGroupFields('');
-               $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
-               $fileTest = $admin->testFileRefs();
-               $code = '';
-               if (is_array($fileTest['noReferences'])) {
-                       foreach ($fileTest['noReferences'] as $val) {
-                               $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong></nobr><br>';
-                       }
-               } else {
-                       $code = $GLOBALS['LANG']->getLL('no_files_found');
-               }
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, FALSE, TRUE);
-               $code = '';
-               if (is_array($fileTest['moreReferences'])) {
-                       foreach ($fileTest['moreReferences'] as $val) {
-                               $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
-                       }
-               } else {
-                       $code = $GLOBALS['LANG']->getLL('no_files_found');
-               }
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'), $code, FALSE, TRUE);
-               $code = '';
-               if (is_array($fileTest['noFile'])) {
-                       ksort($fileTest['noFile']);
-                       foreach ($fileTest['noFile'] as $val) {
-                               $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
-                       }
-               } else {
-                       $code = $GLOBALS['LANG']->getLL('no_files_found');
-               }
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, FALSE, TRUE);
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), FALSE, TRUE);
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), FALSE, TRUE);
-       }
-
-       /**
-        * Searching for files with a specific pattern
-        *
-        * @return void
-        * @todo Define visibility
-        */
-       public function func_filesearch() {
-               $pattern = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pattern');
-               $pcontent = $GLOBALS['LANG']->getLL('enterRegexPattern') . ' <input type="text" name="pattern" value="' . htmlspecialchars(($pattern ? $pattern : $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'])) . '"> <input type="submit" name="' . $GLOBALS['LANG']->getLL('SearchButton') . '">';
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('findFilename'));
-               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, FALSE, TRUE);
-               if (strcmp($pattern, '')) {
-                       $dirs = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs(PATH_site);
-                       $lines = array();
-                       $depth = 10;
-                       foreach ($dirs as $key => $value) {
-                               $matching_files = array();
-                               $info = '';
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('typo3,typo3conf,tslib,media,t3lib', $value)) {
-                                       $info = $this->findFile(PATH_site . $value . '/', $pattern, $matching_files, $depth);
-                               }
-                               if (is_array($info)) {
-                                       $lines[] = '<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('beingChecked');
-                                       $lines[] = $GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
-                                       if ($info[2]) {
-                                               $lines[] = '<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
-                                       }
-                                       $lines[] = $GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
-                                       $lines[] = $GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
-                               } else {
-                                       $lines[] = $GLOBALS['TBE_TEMPLATE']->dfw('<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('notChecked'));
-                               }
-                       }
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), FALSE, TRUE);
-               }
-       }
-
-       /**
-        * Searching for filename pattern recursively in the specified dir.
-        *
-        * @param string $basedir Base directory
-        * @param string $pattern Match pattern
-        * @param array $matching_files Array of matching files, passed by reference
-        * @param integer $depth Depth to recurse
-        * @return array Array with various information about the search result
-        * @see func_filesearch()
-        * @todo Define visibility
-        */
-       public function findFile($basedir, $pattern, &$matching_files, $depth) {
-               $files_searched = 0;
-               $dirs_searched = 0;
-               $dirs_error = 0;
-               // Traverse files:
-               $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($basedir, '', 1);
-               if (is_array($files)) {
-                       $files_searched += count($files);
-                       // Escape the regexp. Note: we cannot use preg_quote here because it will escape more than we need!
-                       $regExpPattern = str_replace('/', '\\/', $pattern);
-                       foreach ($files as $value) {
-                               if (preg_match('/' . $regExpPattern . '/i', basename($value))) {
-                                       $matching_files[] = substr($value, strlen(PATH_site));
-                               }
-                       }
-               }
-               // Traverse subdirs
-               if ($depth > 0) {
-                       $dirs = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs($basedir);
-                       if (is_array($dirs)) {
-                               $dirs_searched += count($dirs);
-                               foreach ($dirs as $value) {
-                                       $inf = $this->findFile($basedir . $value . '/', $pattern, $matching_files, $depth - 1);
-                                       $dirs_searched += $inf[0];
-                                       $files_searched += $inf[1];
-                                       $dirs_error = $inf[2];
-                               }
-                       }
-               } else {
-                       $dirs = \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs($basedir);
-                       if (is_array($dirs) && count($dirs)) {
-                               // Means error - there were further subdirs!
-                               $dirs_error = 1;
-                       }
-               }
-               return array($dirs_searched, $files_searched, $dirs_error);
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Migrations/Code/ClassAliasMap.php b/typo3/sysext/integrity/Migrations/Code/ClassAliasMap.php
deleted file mode 100644 (file)
index 6edc7da..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-return array(
-       'tx_lowlevel_admin_core' => 'TYPO3\\CMS\\Integrity\\AdminCommand',
-       'tx_lowlevel_cleaner_core' => 'TYPO3\\CMS\\Integrity\\CleanerCommand',
-       'tx_lowlevel_cleanflexform' => 'TYPO3\\CMS\\Integrity\\CleanFlexformCommand',
-       'tx_lowlevel_deleted' => 'TYPO3\\CMS\\Integrity\\DeletedRecordsCommand',
-       'tx_lowlevel_double_files' => 'TYPO3\\CMS\\Integrity\\DoubleFilesCommand',
-       'tx_lowlevel_lost_files' => 'TYPO3\\CMS\\Integrity\\LostFilesCommand',
-       'tx_lowlevel_missing_files' => 'TYPO3\\CMS\\Integrity\\MissingFilesCommand',
-       'tx_lowlevel_missing_relations' => 'TYPO3\\CMS\\Integrity\\MissingRelationsCommand',
-       'tx_lowlevel_orphan_records' => 'TYPO3\\CMS\\Integrity\\OrphanRecordsCommand',
-       'tx_lowlevel_rte_images' => 'TYPO3\\CMS\\Integrity\\RteImagesCommand',
-       'tx_lowlevel_syslog' => 'TYPO3\\CMS\\Integrity\\SyslogCommand',
-       't3lib_arrayBrowser' => 'TYPO3\\CMS\\Integrity\\Utility\\ArrayBrowser',
-       'tx_lowlevel_versions' => 'TYPO3\\CMS\\Integrity\\VersionsCommand',
-       'SC_mod_tools_config_index' => 'TYPO3\\CMS\\Integrity\\View\\ConfigurationView',
-       'SC_mod_tools_dbint_index' => 'TYPO3\\CMS\\Integrity\\View\\DatabaseIntegrityView',
-);
-?>
\ No newline at end of file
diff --git a/typo3/sysext/integrity/Tests/Unit/Utility/ArrayBrowserTest.php b/typo3/sysext/integrity/Tests/Unit/Utility/ArrayBrowserTest.php
deleted file mode 100644 (file)
index dafa243..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-namespace TYPO3\CMS\Integrity\Tests\Unit\Utility;
-
-/***************************************************************
- * Copyright notice
- *
- * (c) 2010-2011 Oliver Klee (typo3-coding@oliverklee.de)
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Testcase for the \TYPO3\CMS\Integrity\Utility\ArrayBrowser class in the TYPO3 Core.
- *
- * @package TYPO3
- * @subpackage t3lib
- * @author Oliver Klee <typo3-coding@oliverklee.de>
- */
-class ArrayBrowserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Integrity\Utility\ArrayBrowser
-        */
-       private $fixture;
-
-       public function setUp() {
-               $this->fixture = new \TYPO3\CMS\Integrity\Utility\ArrayBrowser();
-       }
-
-       public function tearDown() {
-               unset($this->fixture);
-       }
-
-       ///////////////////////////////
-       // Tests concerning depthKeys
-       ///////////////////////////////
-       /**
-        * @test
-        */
-       public function depthKeysWithEmptyFirstParameterAddsNothing() {
-               $this->assertEquals(array(), $this->fixture->depthKeys(array(), array()));
-       }
-
-       /**
-        * @test
-        */
-       public function depthKeysWithNumericKeyAddsOneNumberForKeyFromFirstArray() {
-               $this->assertEquals(array(0 => 1), $this->fixture->depthKeys(array('foo'), array()));
-       }
-
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/lowlevel/Classes/AdminCommand.php b/typo3/sysext/lowlevel/Classes/AdminCommand.php
new file mode 100644 (file)
index 0000000..025f9ba
--- /dev/null
@@ -0,0 +1,132 @@
+<?php
+namespace TYPO3\CMS\Lowlevel;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Core functions for admin
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * Core functions for administration
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_lowlevel
+ */
+class AdminCommand extends \TYPO3\CMS\Core\Controller\CommandLineController {
+
+       /**
+        * @todo Define visibility
+        */
+       public $adminModules = array(
+               'setBElock' => 'Set the Backend Lock',
+               'clearBElock' => 'Clears the Backend Lock',
+               'msg' => 1
+       );
+
+       /**
+        * Constructor
+        *
+        * @todo Define visibility
+        */
+       public function __construct() {
+               // Running parent class constructor
+               parent::__construct();
+               // Adding options to help archive:
+               $this->cli_options[] = array('--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.');
+               // Setting help texts:
+               $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line';
+               $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
+               $this->cli_help['description'] = 'The \'toolkey\' keywords are:
+
+  ' . implode('
+  ', array_keys($this->adminModules));
+               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/';
+               $this->cli_help['author'] = 'Kasper Skaarhoej, (c) 2009';
+       }
+
+       /**************************
+        *
+        * CLI functionality
+        *
+        *************************/
+       /**
+        * CLI engine
+        *
+        * @param array $argv Command line arguments
+        * @return string
+        * @todo Define visibility
+        */
+       public function cli_main($argv) {
+               // Force user to admin state and set workspace to "Live":
+               $GLOBALS['BE_USER']->user['admin'] = 1;
+               $GLOBALS['BE_USER']->setWorkspace(0);
+               // Print help
+               $analysisType = (string) $this->cli_args['_DEFAULT'][1];
+               if (!$analysisType) {
+                       $this->cli_validateArgs();
+                       $this->cli_help();
+                       die;
+               }
+               // Analysis type:
+               switch ((string) $analysisType) {
+               case 'setBElock':
+                       if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
+                               $this->cli_echo('A lockfile already exists. Overwriting it...
+');
+                       }
+                       $lockFileContent = $this->cli_argValue('--redirect');
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', $lockFileContent);
+                       $this->cli_echo('Wrote lock-file to \'' . PATH_typo3conf . 'LOCK_BACKEND\' with content \'' . $lockFileContent . '\'');
+                       break;
+               case 'clearBElock':
+                       if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
+                               unlink(PATH_typo3conf . 'LOCK_BACKEND');
+                               if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
+                                       $this->cli_echo('ERROR: Could not remove lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'!!
+', 1);
+                               } else {
+                                       $this->cli_echo('Removed lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'
+');
+                               }
+                       } else {
+                               $this->cli_echo('No lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\' was found; hence no lock can be removed.\'
+');
+                       }
+                       break;
+               default:
+                       $this->cli_echo('Unknown toolkey, \'' . $analysisType . '\'');
+                       break;
+               }
+               $this->cli_echo(LF);
+       }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/lowlevel/Classes/CleanFlexformCommand.php b/typo3/sysext/lowlevel/Classes/CleanFlexformCommand.php
new file mode 100644 (file)
index 0000000..98a857f
--- /dev/null
@@ -0,0 +1,177 @@
+<?php
+namespace TYPO3\CMS\Lowlevel;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Cleaner module: cleanflexform
+ * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * cleanflexform
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_lowlevel
+ */
+class CleanFlexformCommand extends CleanerCommand {
+
+       /**
+        * Constructor
+        *
+        * @todo Define visibility
+        */
+       public function __construct() {
+               parent::__construct();
+               // Setting up help:
+               $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.');
+               $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
+               $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.');
+               $this->cli_help['name'] = 'cleanflexform -- Find flexform fields with unclean XML';
+               $this->cli_help['description'] = trim('
+Traversing page tree and finding records with FlexForm fields with XML that could be cleaned up. This will just remove obsolete data garbage.
+
+Automatic Repair:
+Cleaning XML for FlexForm fields.
+');
+               $this->cli_help['examples'] = '';
+       }
+
+       /**
+        * Find orphan records
+        * VERY CPU and memory intensive since it will look up the whole page tree!
+        *
+        * @return array
+        * @todo Define visibility
+        */
+       public function main() {
+               global $TYPO3_DB;
+               // Initialize result array:
+               $resultArray = array(
+                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
+                       'headers' => array(
+                               'dirty' => array('', '', 2)
+                       ),
+                       'dirty' => array()
+               );
+               $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
+               $depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
+               $this->cleanFlexForm_dirtyFields =& $resultArray['dirty'];
+               // Do not repair flexform data in deleted records.
+               $this->genTree_traverseDeleted = FALSE;
+               $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'), 'main_parseTreeCallBack');
+               asort($resultArray);
+               return $resultArray;
+       }
+
+       /**
+        * Call back function for page tree traversal!
+        *
+        * @param string $tableName Table name
+        * @param integer $uid UID of record in processing
+        * @param integer $echoLevel Echo level  (see calling function
+        * @param string $versionSwapmode Version swap mode on that level (see calling function
+        * @param integer $rootIsVersion Is root version (see calling function
+        * @return void
+        * @todo Define visibility
+        */
+       public function main_parseTreeCallBack($tableName, $uid, $echoLevel, $versionSwapmode, $rootIsVersion) {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName);
+               foreach ($GLOBALS['TCA'][$tableName]['columns'] as $colName => $config) {
+                       if ($config['config']['type'] == 'flex') {
+                               if ($echoLevel > 2) {
+                                       echo LF . '                     [cleanflexform:] Field "' . $colName . '" in ' . $tableName . ':' . $uid . ' was a flexform and...';
+                               }
+                               $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($tableName, 'uid=' . intval($uid));
+                               $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
+                               if ($recRow[$colName]) {
+                                       // Clean XML:
+                                       $newXML = $flexObj->cleanFlexFormXML($tableName, $colName, $recRow);
+                                       if (md5($recRow[$colName]) != md5($newXML)) {
+                                               if ($echoLevel > 2) {
+                                                       echo ' was DIRTY, needs cleanup!';
+                                               }
+                                               $this->cleanFlexForm_dirtyFields[\TYPO3\CMS\Core\Utility\GeneralUtility::shortMd5($tableName . ':' . $uid . ':' . $colName)] = $tableName . ':' . $uid . ':' . $colName;
+                                       } else {
+                                               if ($echoLevel > 2) {
+                                                       echo ' was CLEAN';
+                                               }
+                                       }
+                               } elseif ($echoLevel > 2) {
+                                       echo ' was EMPTY';
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Mandatory autofix function
+        * Will run auto-fix on the result array. Echos status during processing.
+        *
+        * @param array $resultArray Result array from main() function
+        * @return void
+        * @todo Define visibility
+        */
+       public function main_autoFix($resultArray) {
+               foreach ($resultArray['dirty'] as $fieldID) {
+                       list($table, $uid, $field) = explode(':', $fieldID);
+                       echo 'Cleaning XML in "' . $fieldID . '": ';
+                       if ($bypass = $this->cli_noExecutionCheck($fieldID)) {
+                               echo $bypass;
+                       } else {
+                               // Clean XML:
+                               $data = array();
+                               $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($table, 'uid=' . intval($uid));
+                               $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
+                               if ($recRow[$field]) {
+                                       $data[$table][$uid][$field] = $flexObj->cleanFlexFormXML($table, $field, $recRow);
+                               }
+                               // Execute Data array:
+                               $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
+                               $tce->stripslashes_values = FALSE;
+                               $tce->dontProcessTransformations = TRUE;
+                               $tce->bypassWorkspaceRestrictions = TRUE;
+                               $tce->bypassFileHandling = TRUE;
+                               // Check has been done previously that there is a backend user which is Admin and also in live workspace
+                               $tce->start($data, array());
+                               $tce->process_datamap();
+                               // Return errors if any:
+                               if (count($tce->errorLog)) {
+                                       echo '  ERROR from "TCEmain":' . LF . 'TCEmain:' . implode((LF . 'TCEmain:'), $tce->errorLog);
+                               } else {
+                                       echo 'DONE';
+                               }
+                       }
+                       echo LF;
+               }
+       }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/lowlevel/Classes/CleanerCommand.php b/typo3/sysext/lowlevel/Classes/CleanerCommand.php
new file mode 100644 (file)
index 0000000..7fa596d
--- /dev/null
@@ -0,0 +1,582 @@
+<?php
+namespace TYPO3\CMS\Lowlevel;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Core functions for cleaning and analysing
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * Core functions for cleaning and analysing
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_lowlevel
+ */
+class CleanerCommand extends \TYPO3\CMS\Core\Controller\CommandLineController {
+
+       /**
+        * @todo Define visibility
+        */
+       public $genTree_traverseDeleted = TRUE;
+
+       /**
+        * @todo Define visibility
+        */
+       public $genTree_traverseVersions = TRUE;
+
+       /**
+        * @todo Define visibility
+        */
+       public $label_infoString = 'The list of records is organized as [table]:[uid]:[field]:[flexpointer]:[softref_key]';
+
+       /**
+        * @todo Define visibility
+        */
+       public $pagetreePlugins = array();
+
+       /**
+        * @todo Define visibility
+        */
+       public $cleanerModules = array();
+
+       /**
+        * @todo Define visibility
+        */
+       public $performanceStatistics = array();
+
+       protected $workspaceIndex = array();
+
+       /**
+        * Constructor
+        *
+        * @todo Define visibility
+        */
+       public function __construct() {
+               // Running parent class constructor
+               parent::__construct();
+               $this->cleanerModules = (array) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lowlevel']['cleanerModules'];
+               // Adding options to help archive:
+               $this->cli_options[] = array('-r', 'Execute this tool, otherwise help is shown');
+               $this->cli_options[] = array('-v level', 'Verbosity level 0-3', 'The value of level can be:
+  0 = all output
+  1 = info and greater (default)
+  2 = warnings and greater
+  3 = errors');
+               $this->cli_options[] = array('--refindex mode', 'Mode for reference index handling for operations that require a clean reference index ("update"/"ignore")', 'Options are "check" (default), "update" and "ignore". By default, the reference index is checked before running analysis that require a clean index. If the check fails, the analysis is not run. You can choose to bypass this completely (using value "ignore") or ask to have the index updated right away before the analysis (using value "update")');
+               $this->cli_options[] = array('--AUTOFIX [testName]', 'Repairs errors that can be automatically fixed.', 'Only add this option after having run the test without it so you know what will happen when you add this option! The optional parameter "[testName]" works for some tool keys to limit the fixing to a particular test.');
+               $this->cli_options[] = array('--dryrun', 'With --AUTOFIX it will only simulate a repair process', 'You may like to use this to see what the --AUTOFIX option will be doing. It will output the whole process like if a fix really occurred but nothing is in fact happening');
+               $this->cli_options[] = array('--YES', 'Implicit YES to all questions', 'Use this with EXTREME care. The option "-i" is not affected by this option.');
+               $this->cli_options[] = array('-i', 'Interactive', 'Will ask you before running the AUTOFIX on each element.');
+               $this->cli_options[] = array('--filterRegex expr', 'Define an expression for preg_match() that must match the element ID in order to auto repair it', 'The element ID is the string in quotation marks when the text \'Cleaning ... in "ELEMENT ID"\'. "expr" is the expression for preg_match(). To match for example "Nature3.JPG" and "Holiday3.JPG" you can use "/.*3.JPG/". To match for example "Image.jpg" and "Image.JPG" you can use "/.*.jpg/i". Try a --dryrun first to see what the matches are!');
+               $this->cli_options[] = array('--showhowto', 'Displays HOWTO file for cleaner script.');
+               // Setting help texts:
+               $this->cli_help['name'] = 'lowlevel_cleaner -- Analysis and clean-up tools for TYPO3 installations';
+               $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
+               $this->cli_help['description'] = 'Dispatches to various analysis and clean-up tools which can plug into the API of this script. Typically you can run tests that will take longer than the usual max execution time of PHP. Such tasks could be checking for orphan records in the page tree or flushing all published versions in the system. For the complete list of options, please explore each of the \'toolkey\' keywords below:
+
+  ' . implode('
+  ', array_keys($this->cleanerModules));
+               $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_cleaner missing_files -s -r
+This will show you missing files in the TYPO3 system and only report back if errors were found.';
+               $this->cli_help['author'] = 'Kasper Skaarhoej, (c) 2006';
+       }
+
+       /**************************
+        *
+        * CLI functionality
+        *
+        *************************/
+       /**
+        * CLI engine
+        *
+        * @param array $argv Command line arguments
+        * @return string
+        * @todo Define visibility
+        */
+       public function cli_main($argv) {
+               // Force user to admin state and set workspace to "Live":
+               $GLOBALS['BE_USER']->user['admin'] = 1;
+               $GLOBALS['BE_USER']->setWorkspace(0);
+               // Print Howto:
+               if ($this->cli_isArg('--showhowto')) {
+                       $howto = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Extension\ExtensionManager::extPath('lowlevel') . 'HOWTO_clean_up_TYPO3_installations.txt');
+                       echo wordwrap($howto, 120) . LF;
+                       die;
+               }
+               // Print help
+               $analysisType = (string) $this->cli_args['_DEFAULT'][1];
+               if (!$analysisType) {
+                       $this->cli_validateArgs();
+                       $this->cli_help();
+                       die;
+               }
+               // Analysis type:
+               switch ((string) $analysisType) {
+               default:
+                       if (is_array($this->cleanerModules[$analysisType])) {
+                               $cleanerMode = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($this->cleanerModules[$analysisType][0]);
+                               $cleanerMode->cli_validateArgs();
+                               // Run it...
+                               if ($this->cli_isArg('-r')) {
+                                       if (!$cleanerMode->checkRefIndex || $this->cli_referenceIndexCheck()) {
+                                               $res = $cleanerMode->main();
+                                               $this->cli_printInfo($analysisType, $res);
+                                               // Autofix...
+                                               if ($this->cli_isArg('--AUTOFIX')) {
+                                                       if ($this->cli_isArg('--YES') || $this->cli_keyboardInput_yes('
+
+NOW Running --AUTOFIX on result. OK?' . ($this->cli_isArg('--dryrun') ? ' (--dryrun simulation)' : ''))) {
+                                                               $cleanerMode->main_autofix($res);
+                                                       } else {
+                                                               $this->cli_echo('ABORTING AutoFix...
+', 1);
+                                                       }
+                                               }
+                                       }
+                               } else {
+                                       // Help only...
+                                       $cleanerMode->cli_help();
+                                       die;
+                               }
+                       } else {
+                               $this->cli_echo('ERROR: Analysis Type \'' . $analysisType . '\' is unknown.
+', 1);
+                               die;
+                       }
+                       break;
+               }
+       }
+
+       /**
+        * Checks reference index
+        *
+        * @return boolean TRUE if reference index was OK (either OK, updated or ignored)
+        * @todo Define visibility
+        */
+       public function cli_referenceIndexCheck() {
+               // Reference index option:
+               $refIndexMode = isset($this->cli_args['--refindex']) ? $this->cli_args['--refindex'][0] : 'check';
+               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('update,ignore,check', $refIndexMode)) {
+                       $this->cli_echo('ERROR: Wrong value for --refindex argument.
+', 1);
+                       die;
+               }
+               switch ($refIndexMode) {
+               case 'check':
+
+               case 'update':
+                       $refIndexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
+                       list($headerContent, $bodyContent, $errorCount) = $refIndexObj->updateIndex($refIndexMode == 'check', $this->cli_echo());
+                       if ($errorCount && $refIndexMode == 'check') {
+                               $ok = FALSE;
+                               $this->cli_echo('ERROR: Reference Index Check failed! (run with \'--refindex update\' to fix)
+', 1);
+                       } else {
+                               $ok = TRUE;
+                       }
+                       break;
+               case 'ignore':
+                       $this->cli_echo('Reference Index Check: Bypassing reference index check...
+');
+                       $ok = TRUE;
+                       break;
+               }
+               return $ok;
+       }
+
+       /**
+        * @param string $matchString
+        * @return string If string, it's the reason for not executing. Returning FALSE means it should execute.
+        * @todo Define visibility
+        */
+       public function cli_noExecutionCheck($matchString) {
+               // Check for filter:
+               if ($this->cli_isArg('--filterRegex') && ($regex = $this->cli_argValue('--filterRegex', 0))) {
+                       if (!preg_match($regex, $matchString)) {
+                               return 'BYPASS: Filter Regex "' . $regex . '" did not match string "' . $matchString . '"';
+                       }
+               }
+               // Check for interactive mode
+               if ($this->cli_isArg('-i')) {
+                       if (!$this->cli_keyboardInput_yes(' EXECUTE?')) {
+                               return 'BYPASS...';
+                       }
+               }
+               // Check for
+               if ($this->cli_isArg('--dryrun')) {
+                       return 'BYPASS: --dryrun set';
+               }
+       }
+
+       /**
+        * Formats a result array from a test so it fits output in the shell
+        *
+        * @param string $header Name of the test (eg. function name)
+        * @param array $res Result array from an analyze function
+        * @return void Outputs with echo - capture content with output buffer if needed.
+        * @todo Define visibility
+        */
+       public function cli_printInfo($header, $res) {
+               $detailLevel = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_isArg('-v') ? $this->cli_argValue('-v') : 1, 0, 3);
+               $silent = !$this->cli_echo();
+               $severity = array(
+                       0 => 'MESSAGE',
+                       1 => 'INFO',
+                       2 => 'WARNING',
+                       3 => 'ERROR'
+               );
+               // Header output:
+               if ($detailLevel <= 1) {
+                       $this->cli_echo('*********************************************
+' . $header . LF . '*********************************************
+');
+                       $this->cli_echo(wordwrap(trim($res['message'])) . LF . LF);
+               }
+               // Traverse headers for output:
+               if (is_array($res['headers'])) {
+                       foreach ($res['headers'] as $key => $value) {
+                               if ($detailLevel <= intval($value[2])) {
+                                       if (is_array($res[$key]) && (count($res[$key]) || !$silent)) {
+                                               // Header and explanaion:
+                                               $this->cli_echo('---------------------------------------------' . LF, 1);
+                                               $this->cli_echo('[' . $header . ']' . LF, 1);
+                                               $this->cli_echo($value[0] . ' [' . $severity[$value[2]] . ']' . LF, 1);
+                                               $this->cli_echo('---------------------------------------------' . LF, 1);
+                                               if (trim($value[1])) {
+                                                       $this->cli_echo('Explanation: ' . wordwrap(trim($value[1])) . LF . LF, 1);
+                                               }
+                                       }
+                                       // Content:
+                                       if (is_array($res[$key])) {
+                                               if (count($res[$key])) {
+                                                       if ($this->cli_echo('', 1)) {
+                                                               print_r($res[$key]);
+                                                       }
+                                               } else {
+                                                       $this->cli_echo('(None)' . LF . LF);
+                                               }
+                                       } else {
+                                               $this->cli_echo($res[$key] . LF . LF);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**************************
+        *
+        * Page tree traversal
+        *
+        *************************/
+       /**
+        * Traverses the FULL/part of page tree, mainly to register ALL validly connected records (to find orphans) but also to register deleted records, versions etc.
+        * Output (in $this->recStats) can be useful for multiple purposes.
+        *
+        * @param integer $rootID Root page id from where to start traversal. Use "0" (zero) to have full page tree (necessary when spotting orphans, otherwise you can run it on parts only)
+        * @param integer $depth Depth to traverse. zero is do not traverse at all. 1 = 1 sublevel, 1000= 1000 sublevels (all...)
+        * @param boolean $echoLevel If >0, will echo information about the traversal process.
+        * @param string $callBack Call back function (from this class or subclass)
+        * @return void
+        * @todo Define visibility
+        */
+       public function genTree($rootID, $depth = 1000, $echoLevel = 0, $callBack = '') {
+               $pt = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
+               $this->performanceStatistics['genTree()'] = '';
+               // Initialize:
+               if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('workspaces')) {
+                       $this->workspaceIndex = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title', 'sys_workspace', '1=1' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_workspace'), '', '', '', 'uid');
+               }
+               $this->workspaceIndex[-1] = TRUE;
+               $this->workspaceIndex[0] = TRUE;
+               $this->recStats = array(
+                       'all' => array(),
+                       // All records connected in tree including versions (the reverse are orphans). All Info and Warning categories below are included here (and therefore safe if you delete the reverse of the list)
+                       'deleted' => array(),
+                       // Subset of "alL" that are deleted-flagged [Info]
+                       'versions' => array(),
+                       // Subset of "all" which are offline versions (pid=-1). [Info]
+                       'versions_published' => array(),
+                       // Subset of "versions" that is a count of 1 or more (has been published) [Info]
+                       'versions_liveWS' => array(),
+                       // Subset of "versions" that exists in live workspace [Info]
+                       'versions_lost_workspace' => array(),
+                       // Subset of "versions" that doesn't belong to an existing workspace [Warning: Fix by move to live workspace]
+                       'versions_inside_versioned_page' => array(),
+                       // Subset of "versions" This is versions of elements found inside an already versioned branch / page. In real life this can work out, but is confusing and the backend should prevent this from happening to people. [Warning: Fix by deleting those versions (or publishing them)]
+                       'illegal_record_under_versioned_page' => array(),
+                       // If a page is "element" or "page" version and records are found attached to it, they might be illegally attached, so this will tell you. [Error: Fix by deleting orphans since they are not registered in "all" category]
+                       'misplaced_at_rootlevel' => array(),
+                       // Subset of "all": Those that should not be at root level but are. [Warning: Fix by moving record into page tree]
+                       'misplaced_inside_tree' => array()
+               );
+               // Start traversal:
+               $pt2 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
+               $this->performanceStatistics['genTree_traverse()'] = '';
+               $this->performanceStatistics['genTree_traverse():TraverseTables'] = '';
+               $this->genTree_traverse($rootID, $depth, $echoLevel, $callBack);
+               $this->performanceStatistics['genTree_traverse()'] = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt2;
+               // Sort recStats (for diff'able displays)
+               foreach ($this->recStats as $kk => $vv) {
+                       foreach ($this->recStats[$kk] as $tables => $recArrays) {
+                               ksort($this->recStats[$kk][$tables]);
+                       }
+                       ksort($this->recStats[$kk]);
+               }
+               if ($echoLevel > 0) {
+                       echo LF . LF;
+               }
+               // Processing performance statistics:
+               $this->performanceStatistics['genTree()'] = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt;
+               // Count records:
+               foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
+                       // Select all records belonging to page:
+                       $resSub = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tableName, '');
+                       $countRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSub);
+                       $this->performanceStatistics['MySQL_count'][$tableName] = $countRow['count(*)'];
+                       $this->performanceStatistics['CSV'] .= LF . $tableName . ',' . $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL'][$tableName] . ',' . $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc'][$tableName] . ',' . $this->performanceStatistics['MySQL_count'][$tableName];
+               }
+               $this->performanceStatistics['recStats_size']['(ALL)'] = strlen(serialize($this->recStats));
+               foreach ($this->recStats as $key => $arrcontent) {
+                       $this->performanceStatistics['recStats_size'][$key] = strlen(serialize($arrcontent));
+               }
+       }
+
+       /**
+        * Recursive traversal of page tree:
+        *
+        * @param integer $rootID Page root id (must be online, valid page record - or zero for page tree root)
+        * @param integer $depth Depth
+        * @param integer $echoLevel Echo Level
+        * @param string $callBack Call back function (from this class or subclass)
+        * @param string $versionSwapmode DON'T set from outside, internal. (indicates we are inside a version of a page) - will be "SWAPMODE:-1" or empty
+        * @param integer $rootIsVersion DON'T set from outside, internal. (1: Indicates that rootID is a version of a page, 2: ...that it is even a version of a version (which triggers a warning!)
+        * @param string $accumulatedPath Internal string that accumulates the path
+        * @return void
+        * @access private
+        * @todo $versionSwapmode needs to be cleaned up, since page and branch version (0, 1) does not exist anymore
+        * @todo Define visibility
+        */
+       public function genTree_traverse($rootID, $depth, $echoLevel = 0, $callBack = '', $versionSwapmode = '', $rootIsVersion = 0, $accumulatedPath = '') {
+               // Register page:
+               $this->recStats['all']['pages'][$rootID] = $rootID;
+               $pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw('pages', 'uid=' . intval($rootID), 'deleted,title,t3ver_count,t3ver_wsid');
+               $accumulatedPath .= '/' . $pageRecord['title'];
+               // Register if page is deleted:
+               if ($pageRecord['deleted']) {
+                       $this->recStats['deleted']['pages'][$rootID] = $rootID;
+               }
+               // If rootIsVersion is set it means that the input rootID is that of a version of a page. See below where the recursive call is made.
+               if ($rootIsVersion) {
+                       $this->recStats['versions']['pages'][$rootID] = $rootID;
+                       // If it has been published and is in archive now...
+                       if ($pageRecord['t3ver_count'] >= 1 && $pageRecord['t3ver_wsid'] == 0) {
+                               $this->recStats['versions_published']['pages'][$rootID] = $rootID;
+                       }
+                       // If it has been published and is in archive now...
+                       if ($pageRecord['t3ver_wsid'] == 0) {
+                               $this->recStats['versions_liveWS']['pages'][$rootID] = $rootID;
+                       }
+                       // If it doesn't belong to a workspace...
+                       if (!isset($this->workspaceIndex[$pageRecord['t3ver_wsid']])) {
+                               $this->recStats['versions_lost_workspace']['pages'][$rootID] = $rootID;
+                       }
+                       // In case the rootID is a version inside a versioned page
+                       if ($rootIsVersion == 2) {
+                               $this->recStats['versions_inside_versioned_page']['pages'][$rootID] = $rootID;
+                       }
+               }
+               if ($echoLevel > 0) {
+                       echo LF . $accumulatedPath . ' [' . $rootID . ']' . ($pageRecord['deleted'] ? ' (DELETED)' : '') . ($this->recStats['versions_published']['pages'][$rootID] ? ' (PUBLISHED)' : '');
+               }
+               if ($echoLevel > 1 && $this->recStats['versions_lost_workspace']['pages'][$rootID]) {
+                       echo LF . '     ERROR! This version belongs to non-existing workspace (' . $pageRecord['t3ver_wsid'] . ')!';
+               }
+               if ($echoLevel > 1 && $this->recStats['versions_inside_versioned_page']['pages'][$rootID]) {
+                       echo LF . '     WARNING! This version is inside an already versioned page or branch!';
+               }
+               // Call back:
+               if ($callBack) {
+                       $this->{$callBack}('pages', $rootID, $echoLevel, $versionSwapmode, $rootIsVersion);
+               }
+               $pt3 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
+               // Traverse tables of records that belongs to page:
+               foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
+                       if ($tableName != 'pages') {
+                               // Select all records belonging to page:
+                               $pt4 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
+                               $resSub = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid' . ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] : ''), $tableName, 'pid=' . intval($rootID) . ($this->genTree_traverseDeleted ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableName)));
+                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL']['(ALL)'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt4;
+                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['MySQL'][$tableName] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt4;
+                               $pt5 = \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds();
+                               $count = $GLOBALS['TYPO3_DB']->sql_num_rows($resSub);
+                               if ($count) {
+                                       if ($echoLevel == 2) {
+                                               echo LF . '     \\-' . $tableName . ' (' . $count . ')';
+                                       }
+                               }
+                               while ($rowSub = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSub)) {
+                                       if ($echoLevel == 3) {
+                                               echo LF . '     \\-' . $tableName . ':' . $rowSub['uid'];
+                                       }
+                                       // If the rootID represents an "element" or "page" version type, we must check if the record from this table is allowed to belong to this:
+                                       if ($versionSwapmode == 'SWAPMODE:-1' || $versionSwapmode == 'SWAPMODE:0' && !$GLOBALS['TCA'][$tableName]['ctrl']['versioning_followPages']) {
+                                               // This is illegal records under a versioned page - therefore not registered in $this->recStats['all'] so they should be orphaned:
+                                               $this->recStats['illegal_record_under_versioned_page'][$tableName][$rowSub['uid']] = $rowSub['uid'];
+                                               if ($echoLevel > 1) {
+                                                       echo LF . '             ERROR! Illegal record (' . $tableName . ':' . $rowSub['uid'] . ') under versioned page!';
+                                               }
+                                       } else {
+                                               $this->recStats['all'][$tableName][$rowSub['uid']] = $rowSub['uid'];
+                                               // Register deleted:
+                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $rowSub[$GLOBALS['TCA'][$tableName]['ctrl']['delete']]) {
+                                                       $this->recStats['deleted'][$tableName][$rowSub['uid']] = $rowSub['uid'];
+                                                       if ($echoLevel == 3) {
+                                                               echo ' (DELETED)';
+                                                       }
+                                               }
+                                               // Check location of records regarding tree root:
+                                               if (!$GLOBALS['TCA'][$tableName]['ctrl']['rootLevel'] && $rootID == 0) {
+                                                       $this->recStats['misplaced_at_rootlevel'][$tableName][$rowSub['uid']] = $rowSub['uid'];
+                                                       if ($echoLevel > 1) {
+                                                               echo LF . '             ERROR! Misplaced record (' . $tableName . ':' . $rowSub['uid'] . ') on rootlevel!';
+                                                       }
+                                               }
+                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['rootLevel'] == 1 && $rootID > 0) {
+                                                       $this->recStats['misplaced_inside_tree'][$tableName][$rowSub['uid']] = $rowSub['uid'];
+                                                       if ($echoLevel > 1) {
+                                                               echo LF . '             ERROR! Misplaced record (' . $tableName . ':' . $rowSub['uid'] . ') inside page tree!';
+                                                       }
+                                               }
+                                               // Traverse plugins:
+                                               if ($callBack) {
+                                                       $this->{$callBack}($tableName, $rowSub['uid'], $echoLevel, $versionSwapmode, $rootIsVersion);
+                                               }
+                                               // Add any versions of those records:
+                                               if ($this->genTree_traverseVersions) {
+                                                       $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord($tableName, $rowSub['uid'], 'uid,t3ver_wsid,t3ver_count' . ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] : ''), 0, TRUE);
+                                                       if (is_array($versions)) {
+                                                               foreach ($versions as $verRec) {
+                                                                       if (!$verRec['_CURRENT_VERSION']) {
+                                                                               if ($echoLevel == 3) {
+                                                                                       echo LF . '             \\-[#OFFLINE VERSION: WS#' . $verRec['t3ver_wsid'] . '/Cnt:' . $verRec['t3ver_count'] . '] ' . $tableName . ':' . $verRec['uid'] . ')';
+                                                                               }
+                                                                               $this->recStats['all'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                               // Register deleted:
+                                                                               if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $verRec[$GLOBALS['TCA'][$tableName]['ctrl']['delete']]) {
+                                                                                       $this->recStats['deleted'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                                       if ($echoLevel == 3) {
+                                                                                               echo ' (DELETED)';
+                                                                                       }
+                                                                               }
+                                                                               // Register version:
+                                                                               $this->recStats['versions'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                               if ($verRec['t3ver_count'] >= 1 && $verRec['t3ver_wsid'] == 0) {
+                                                                                       // Only register published versions in LIVE workspace (published versions in draft workspaces are allowed)
+                                                                                       $this->recStats['versions_published'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                                       if ($echoLevel == 3) {
+                                                                                               echo ' (PUBLISHED)';
+                                                                                       }
+                                                                               }
+                                                                               if ($verRec['t3ver_wsid'] == 0) {
+                                                                                       $this->recStats['versions_liveWS'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                               }
+                                                                               if (!isset($this->workspaceIndex[$verRec['t3ver_wsid']])) {
+                                                                                       $this->recStats['versions_lost_workspace'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                                       if ($echoLevel > 1) {
+                                                                                               echo LF . '             ERROR! Version (' . $tableName . ':' . $verRec['uid'] . ') belongs to non-existing workspace (' . $verRec['t3ver_wsid'] . ')!';
+                                                                                       }
+                                                                               }
+                                                                               // In case we are inside a versioned branch, there should not exists versions inside that "branch".
+                                                                               if ($versionSwapmode) {
+                                                                                       $this->recStats['versions_inside_versioned_page'][$tableName][$verRec['uid']] = $verRec['uid'];
+                                                                                       if ($echoLevel > 1) {
+                                                                                               echo LF . '             ERROR! This version (' . $tableName . ':' . $verRec['uid'] . ') is inside an already versioned page or branch!';
+                                                                                       }
+                                                                               }
+                                                                               // Traverse plugins:
+                                                                               if ($callBack) {
+                                                                                       $this->{$callBack}($tableName, $verRec['uid'], $echoLevel, $versionSwapmode, $rootIsVersion);
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                                       unset($versions);
+                                               }
+                                       }
+                               }
+                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc']['(ALL)'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt5;
+                               $this->performanceStatistics['genTree_traverse():TraverseTables:']['Proc'][$tableName] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt5;
+                       }
+               }
+               unset($resSub);
+               unset($rowSub);
+               $this->performanceStatistics['genTree_traverse():TraverseTables'] += \TYPO3\CMS\Core\Utility\GeneralUtility::milliseconds() - $pt3;
+               // Find subpages to root ID and traverse (only when rootID is not a version or is a branch-version):
+               if (!$versionSwapmode || $versionSwapmode == 'SWAPMODE:1') {
+                       if ($depth > 0) {
+                               $depth--;
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . intval($rootID) . ($this->genTree_traverseDeleted ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('pages')), '', 'sorting');
+                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                                       $this->genTree_traverse($row['uid'], $depth, $echoLevel, $callBack, $versionSwapmode, 0, $accumulatedPath);
+                               }
+                       }
+                       // Add any versions of pages
+                       if ($rootID > 0 && $this->genTree_traverseVersions) {
+                               $versions = \TYPO3\CMS\Backend\Utility\BackendUtility::selectVersionsOfRecord('pages', $rootID, 'uid,t3ver_oid,t3ver_wsid,t3ver_count', 0, TRUE);
+                               if (is_array($versions)) {
+                                       foreach ($versions as $verRec) {
+                                               if (!$verRec['_CURRENT_VERSION']) {
+                                                       $this->genTree_traverse($verRec['uid'], $depth, $echoLevel, $callBack, 'SWAPMODE:-1', $versionSwapmode ? 2 : 1, $accumulatedPath . ' [#OFFLINE VERSION: WS#' . $verRec['t3ver_wsid'] . '/Cnt:' . $verRec['t3ver_count'] . ']');
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**************************
+        *
+        * Helper functions
+        *
+        *************************/
+       /**
+        * Compile info-string
+        *
+        * @param array $rec Input record from sys_refindex
+        * @return string String identifying the main record of the reference
+        * @todo Define visibility
+        */
+       public function infoStr($rec) {
+               return $rec['tablename'] . ':' . $rec['recuid'] . ':' . $rec['field'] . ':' . $rec['flexpointer'] . ':' . $rec['softref_key'] . ($rec['deleted'] ? ' (DELETED)' : '');
+       }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/lowlevel/Classes/DeletedRecordsCommand.php b/typo3/sysext/lowlevel/Classes/DeletedRecordsCommand.php
new file mode 100644 (file)
index 0000000..ab4a239
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+namespace TYPO3\CMS\Lowlevel;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Cleaner module: Deleted records
+ * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * Looking for Deleted records
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_lowlevel
+ */
+class DeletedRecordsCommand extends CleanerCommand {
+
+       /**
+        * Constructor
+        *
+        * @todo Define visibility
+        */
+       public function __construct() {
+               parent::__construct();
+               // Setting up help:
+               $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.');
+               $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
+               $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.');
+               $this->cli_help['name'] = 'deleted -- To find and flush deleted records in the page tree';
+               $this->cli_help['description'] = trim('
+Traversing page tree and finding deleted records
+
+Automatic Repair:
+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.
+');
+               $this->cli_help['examples'] = '';
+       }
+
+       /**
+        * Find orphan records
+        * VERY CPU and memory intensive since it will look up the whole page tree!
+        *
+        * @return array
+        * @todo Define visibility
+        */
+       public function main() {
+               global $TYPO3_DB;
+               // Initialize result array:
+               $resultArray = array(
+                       'message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'],
+                       'headers' => array(
+                               '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)
+                       ),
+                       'deleted' => array()
+               );
+               $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
+  &n