Commit 30ee6168 authored by Benni Mack's avatar Benni Mack
Browse files

[!!!][TASK] Merge tx_ter_extensiondetails into tx_ter_extensions

There is a simple connection between tx_ter_extensiondetails and tx_ter_extensions
(extensionuid field), but both tables always need to be kept in sync. This is unnecessary
overhead. For this reason, all data is now moved into tx_ter_extensions (which will
later be moved into tx_terfe2_domain_model_version).

After adding the new fields to the database table "tx_ter_extensions",
A onetime CLI command "ter:migrateextensiondetails" is executed
and syncs all existing data into the main "tx_ter_extensions".

"tx_ter_extensiondetails" can be dropped after the migration, as it is not
used anymore at all.
parent a24e80ac
Pipeline #9166 failed with stages
in 1 minute and 4 seconds
......@@ -31,7 +31,6 @@
"ext-dom": "*",
"ext-zlib": "*",
"t3o/ter-layout": "^0.1",
"t3o/ter-soap": "^2.0",
"t3o/ter-frontend": "^0.4",
"helhum/typo3-console": "^5.7",
"apache-solr-for-typo3/solr": "^10.0",
......@@ -41,7 +40,8 @@
"helhum/typo3-secure-web": "^0.2.9",
"typo3/cms-adminpanel": "^9.5",
"typo3/cms-seo": "^9.5",
"ext-json": "*"
"ext-json": "*",
"t3o/ter-soap": "^2.0"
},
"require-dev": {
"nimut/testing-framework": "^4.0",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7c2449eaf26a74398ebf2493ae7b4376",
"content-hash": "689547b69d5a4f2d8b817dd9249650e5",
"packages": [
{
"name": "adoy/fastcgi-client",
......@@ -3814,7 +3814,7 @@
"dist": {
"type": "path",
"url": "extensions/ter",
"reference": "2b1d8e8dda17de5cae1bf32f9ad30e4c3ee37e1e"
"reference": "2bf4b5ee6918d817b55e124f5857aa9e28d14fd5"
},
"require": {
"typo3/cms-core": "^8.7 || ^9.5"
......@@ -3830,8 +3830,7 @@
"classmap": [
"Classes",
"pi1",
"class.tx_ter_api.php",
"class.tx_ter_helper.php"
"class.tx_ter_api.php"
]
},
"license": [
......
......@@ -23,7 +23,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* API class checking against specific versions (= uploaded extensions) of an extensionkey.
*
* This class should also contain "add()" in the future to add files to the extension version.
* In addition, all checks against "tx_ter_extensions" and "tx_ter_extensiondetails" should be coupled in there,
* In addition, all checks against "tx_ter_extensions" should be coupled in there,
* so no outside checks are needed anymore.
*/
class ExtensionVersion
......@@ -74,7 +74,7 @@ class ExtensionVersion
}
/**
* Fetches the UID, currently needed because the "uid" is matched against "tx_ter_extensiondetails.extensionuid".
* Fetches the UID to see if the record exists
*
* @return int|null
*/
......@@ -215,17 +215,13 @@ class ExtensionVersion
);
}
$uidOfExtensionVersion = $this->getUidOfExtensionVersion();
if ($uidOfExtensionVersion === null) {
if (!$this->doesExtensionVersionExist()) {
throw new InternalServerErrorException(
'deleteExtension_deleteFromDBAndRemoveFiles: Extension does not exist. (extensionkey: ' . (string)$this->extensionKey . ' version: ' . $this->version . ')',
ResultCodes::ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
);
}
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensiondetails');
$conn->delete('tx_ter_extensiondetails', ['extensionuid' => $uidOfExtensionVersion]);
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensions');
$affectedRows = $conn->delete('tx_ter_extensions', ['extensionkey' => (string)$this->extensionKey, 'version' => $this->version]);
if (!$affectedRows) {
......
<?php
declare(strict_types=1);
namespace T3o\Ter\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* One time command, can be removed in late 2020.
*/
class MigrateExtensionDetailsCommand extends \Symfony\Component\Console\Command\Command
{
protected function configure()
{
$this->setDescription('One-time-migration. Migrates existing data from tx_ter_extensiondetails into tx_ter_extensions');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->section('Updating all items in tx_ter_extensions now');
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensions');
$queryBuilderForDetails = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_ter_extensiondetails');
$queryBuilderForDetails->getRestrictions()->removeAll();
$statement = $queryBuilderForDetails
->select(
'extensionuid',
'uploadcomment',
'lastuploadbyusername',
'lastuploaddate',
'files',
'techinfo',
'composerinfo',
'dependencies',
'createdirs',
'uploadfolder',
'clearcacheonload',
'authorname',
'authoremail',
'authorcompany'
)
->from('tx_ter_extensiondetails')
->where(
$queryBuilderForDetails->expr()->gt('extensionuid', 0)
)
->execute();
$itemsProcessed = 0;
while ($detailsRow = $statement->fetch()) {
$uid = $detailsRow['extensionuid'];
unset($detailsRow['extensionuid']);
$conn->update('tx_ter_extensions', $detailsRow, ['uid' => $uid]);
$itemsProcessed++;
}
$io->success('Done. Updated ' . $itemsProcessed . ' items');
return 0;
}
}
\ No newline at end of file
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
return [
'ter:migrateextensiondetails' => [
'class' => \T3o\Ter\Command\MigrateExtensionDetailsCommand::class
],
];
<?php
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
'ctrl' => [
'label' => 'extensionuid',
'default_sortby' => 'ORDER BY extensionuid',
'title' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails',
'iconfile' => \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey)) . 'tx_ter_extensiondetails.gif',
'dividers2tabs' => true,
],
'interface' => [
'showRecordFieldList' => '',
],
'columns' => [
'extensionuid' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.extensionuid',
'config' => [
'type' => 'input',
'size' => '15',
'max' => '11',
],
],
'uploadcomment' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.uploadcomment',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'lastuploadbyusername' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.lastuploadbyusername',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '30',
'eval' => 'trim',
],
],
'lastuploaddate' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.lastuploaddate',
'config' => [
'type' => 'input',
'size' => '15',
'max' => '11',
],
],
'files' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.files',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'techinfo' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.techinfo',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'composerinfo' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.composerinfo',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'dependencies' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.dependencies',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'createdirs' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.createdirs',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
],
],
'uploadfolder' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.uploadfolder',
'config' => [
'type' => 'check',
'default' => '0',
],
],
'clearcacheonload' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.clearcacheonload',
'config' => [
'type' => 'check',
'default' => '0',
],
],
'authorname' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.authorname',
'config' => [
'type' => 'input',
'size' => '40',
'eval' => 'trim',
],
],
'authoremail' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.authoremail',
'config' => [
'type' => 'input',
'size' => '40',
'eval' => 'trim',
],
],
'authorcompany' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails.authorcompany',
'config' => [
'type' => 'input',
'size' => '40',
'eval' => 'trim',
],
],
],
'types' => [
'1' => ['showitem' => 'extensionuid,uploadcomment,lastuploadbyusername,lastuploaddate,files,techinfo,dependencies,createdirs,uploadfolder,clearcacheonload,authorname,authoremail,authorcompany'],
]
];
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
'ctrl' => [
......@@ -20,8 +19,7 @@ return [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'title' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionkeys',
'iconfile' => \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey)) . 'tx_ter_extensionkeys.gif',
'dividers2tabs' => true,
'iconfile' => 'EXT:ter/tx_ter_extensionkeys.gif',
],
'interface' => [
'showRecordFieldList' => 'extensionkey',
......@@ -31,8 +29,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionkeys.title',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '250',
'size' => 40,
'max' => 250,
'eval' => 'trim,required',
],
],
......@@ -40,16 +38,16 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionkeys.description',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '5',
'cols' => 40,
'rows' => 5,
],
],
'extensionkey' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionkeys.extensionkey',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '30',
'size' => 40,
'max' => 30,
'eval' => 'trim,unique,required',
],
],
......@@ -57,8 +55,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionkeys.ownerusername',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '30',
'size' => 40,
'max' => 30,
'eval' => 'trim',
],
],
......@@ -66,8 +64,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.downloadcounter',
'config' => [
'type' => 'input',
'size' => '5',
'max' => '11',
'size' => 5,
'max' => 11,
],
],
],
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
'ctrl' => [
......@@ -20,8 +19,7 @@ return [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'title' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions',
'iconfile' => \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey)) . 'tx_ter_extensions.gif',
'dividers2tabs' => true,
'iconfile' => 'EXT:ter/tx_ter_extensions.gif',
],
'interface' => [
'showRecordFieldList' => '',
......@@ -31,8 +29,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.extensionkey',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '30',
'size' => 40,
'max' => 30,
'eval' => 'trim',
],
],
......@@ -40,8 +38,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.version',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '50',
'size' => 40,
'max' => 50,
'eval' => 'trim',
],
],
......@@ -49,8 +47,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.title',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '50',
'size' => 40,
'max' => 50,
'eval' => 'trim',
],
],
......@@ -58,16 +56,16 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.description',
'config' => [
'type' => 'text',
'cols' => '40',
'rows' => '3',
'cols' => 40,
'rows' => 3,
],
],
'state' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.state',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '15',
'size' => 40,
'max' => 15,
'eval' => 'trim',
],
],
......@@ -75,16 +73,16 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.reviewstate',
'config' => [
'type' => 'input',
'size' => '5',
'max' => '5',
'size' => 5,
'max' => 5,
],
],
'category' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.category',
'config' => [
'type' => 'input',
'size' => '40',
'max' => '30',
'size' => 40,
'max' => 30,
'eval' => 'trim',
],
],
......@@ -92,8 +90,8 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.downloadcounter',
'config' => [
'type' => 'input',
'size' => '5',
'max' => '5',
'size' => 5,
'max' => 5,
],
],
'ismanualincluded' => [
......@@ -107,13 +105,116 @@ return [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.t3xfilemd5',
'config' => [
'type' => 'input',
'size' => '32',
'max' => '32',
'size' => 32,
'max' => 32,
'eval' => 'trim',
],
],
'uploadcomment' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.uploadcomment',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'lastuploadbyusername' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.lastuploadbyusername',
'config' => [
'type' => 'input',
'size' => 40,
'max' => 30,
'eval' => 'trim',
],
],
'lastuploaddate' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.lastuploaddate',
'config' => [
'type' => 'input',
'size' => 15,
'max' => 11,
],
],
'files' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.files',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'techinfo' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.techinfo',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'composerinfo' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.composerinfo',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'dependencies' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.dependencies',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'createdirs' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.createdirs',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
],
],
'uploadfolder' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.uploadfolder',
'config' => [
'type' => 'check',
'default' => '0',
],
],
'clearcacheonload' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.clearcacheonload',
'config' => [
'type' => 'check',
'default' => '0',
],
],
'authorname' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.authorname',
'config' => [
'type' => 'input',
'size' => 40,
'eval' => 'trim',
],
],
'authoremail' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.authoremail',
'config' => [
'type' => 'input',
'size' => 40,
'eval' => 'trim',
],
],
'authorcompany' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensions.authorcompany',
'config' => [
'type' => 'input',
'size' => 40,
'eval' => 'trim',
],
],
],