Skip to content

Instantly share code, notes, and snippets.

@xperseguers
Created February 22, 2017 10:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xperseguers/08c2d55129d3c18e51561cec15afe69e to your computer and use it in GitHub Desktop.
Save xperseguers/08c2d55129d3c18e51561cec15afe69e to your computer and use it in GitHub Desktop.
TYPO3 TCA Migration helper
This patch was tested against TYPO3 v7.
Purpose is to *temporarily and quickly* let you export the migrated TCA to a file within typo3temp/migrated_TCA/<table_name>.migrated.php
so that you may then use any diff tool to compare the migrated TCA of a given table with your own definition.
To run it, just open backend module "Configuration -> TCA". This will automatically dump the whole (migrated) TCA to the disk.
This is not perfect but should help you a lot anyway to go through the various deprecation messages in typo3conf/deprecation_*.log.
Have fun!
diff --git a/typo3/sysext/lowlevel/Classes/View/ConfigurationView.php b/typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
index b16bea7914..15c9fc7495 100644
--- a/typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
+++ b/typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
@@ -151,6 +151,68 @@ class ConfigurationView extends BaseScriptClass
case 1:
$theVar = $GLOBALS['TCA'];
ArrayUtility::naturalKeySortRecursive($theVar);
+ // DEBUG
+ $tempDirectory = PATH_site . 'typo3temp/migrated_TCA/';
+ GeneralUtility::mkdir($tempDirectory);
+ foreach ($theVar as $tableName => $config) {
+ try {
+ // Put the TCA keys in "same order as before"
+ $configuration = [];
+ if (preg_match('/^tx_(.*)_domain_model_(.*)$/', $tableName, $matches)) {
+ $extensionName = $matches[1];
+ // TODO: adapt prefix if your custom extensions are of the form "mycompany_something" cause
+ // tables will be prefixed tx_mycompanysomething_
+ $myPrefix = 'mycompany';
+ if (GeneralUtility::isFirstPartOfStr($extensionName, $myPrefix) && substr($extensionName, strlen($myPrefix), 1) !== '_') {
+ $extensionName = $myPrefix . '_' . substr($extensionName, strlen($myPrefix));
+ }
+ if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extensionName)) {
+ $configurationPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionName) . 'Configuration/TCA/';
+ if (is_file($configurationPath . $tableName . '.php')) {
+ $oldTca = include($configurationPath . $tableName . '.php');
+ $newTca = [];
+ foreach ($oldTca as $tcaPart => $c1) {
+ foreach ($c1 as $k1 => $c2) {
+ if (!is_array($c2)) {
+ if (isset($config[$tcaPart][$k1])) {
+ $newTca[$tcaPart][$k1] = $config[$tcaPart][$k1];
+ }
+ } else {
+ foreach ($c2 as $k2 => $_) {
+ if (isset($config[$tcaPart][$k1][$k2])) {
+ $newTca[$tcaPart][$k1][$k2] = $config[$tcaPart][$k1][$k2];
+ }
+ }
+ }
+ }
+ }
+ $configuration = $newTca;
+ }
+ }
+ }
+ if (empty($configuration)) {
+ $configuration = [
+ 'ctrl' => $config['ctrl'],
+ 'interface' => $config['interface'],
+ 'palettes' => $config['palettes'],
+ 'types' => $config['types'],
+ 'columns' => $config['columns'],
+ ];
+ }
+
+ GeneralUtility::writeFile(
+ $tempDirectory . $tableName . '.migrated.php',
+ '<?php' . LF .
+ 'return ' .
+ ArrayUtility::arrayExport($configuration) .
+ ';' . LF,
+ true
+ );
+ } catch (\Exception $e) {
+ // do nothing
+ }
+ }
+ // END DEBUG
$arrayBrowser->varName = '$TCA';
break;
case 2:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment