Commit 9269545f authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch '484-store-tx_terfe2_domain_model_version-dependencies-as-json' into 'develop'

[TASK] Store tx_terfe2_domain_model_version.dependencies as JSON

Closes #484

See merge request t3o/ter!600
parents 17b0a793 9fafa608
Pipeline #9922 passed with stages
in 5 minutes and 36 seconds
......@@ -45,16 +45,16 @@
},
{
"name": "apache-solr-for-typo3/solr",
"version": "11.0.2",
"version": "11.0.3",
"source": {
"type": "git",
"url": "https://github.com/TYPO3-Solr/ext-solr.git",
"reference": "d1a6b0f9528c934ea16cf2536527b9348e7ef9fe"
"reference": "72e46df4c4a99f8cf3fdd7d9e5b89e9b9b044ca6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3-Solr/ext-solr/zipball/d1a6b0f9528c934ea16cf2536527b9348e7ef9fe",
"reference": "d1a6b0f9528c934ea16cf2536527b9348e7ef9fe",
"url": "https://api.github.com/repos/TYPO3-Solr/ext-solr/zipball/72e46df4c4a99f8cf3fdd7d9e5b89e9b9b044ca6",
"reference": "72e46df4c4a99f8cf3fdd7d9e5b89e9b9b044ca6",
"shasum": ""
},
"require": {
......@@ -87,6 +87,9 @@
"extension-key": "solr",
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": ".Build/Web"
},
"patches_applied": {
"Do not throw exception for wrong sorting parameter": "patches/sorting-field.diff"
}
},
"autoload": {
......@@ -122,7 +125,7 @@
"type": "custom"
}
],
"time": "2020-06-15T12:46:05+00:00"
"time": "2020-09-25T19:42:15+00:00"
},
{
"name": "causal/ig_ldap_sso_auth",
......
......@@ -546,9 +546,9 @@ class ExtensionVersion
'software_relations' => 0,
't3x_file_size' => @filesize($t3xFile),
'zip_file_size' => 0,
'composer_info' => json_encode($composerInfo),
'composer_info' => json_encode($composerInfo) ?: '',
'compatible_typo3_versions' => VersionUtility::getCompatibleTypo3Versions($dependenciesArr),
'dependencies' => (string)serialize($dependenciesArr),
'dependencies' => json_encode($dependenciesArr) ?: '',
'authorname' => (string)$extensionInfoData->metaData->authorName,
'authoremail' => (string)$extensionInfoData->metaData->authorEmail,
'authorcompany' => (string)$extensionInfoData->metaData->authorCompany,
......
<?php
declare(strict_types = 1);
namespace T3o\TerFe2\Command;
/*
* 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!
*/
use Symfony\Component\Console\Command\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 MigrateDependenciesToJson extends Command
{
protected function configure(): void
{
$this->setDescription('One-time-migration. Migrates tx_terfe2_domain_model_version.dependencies from serialized array to JSON.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$io->section('Updating field \'dependencies\' of all \'tx_terfe2_domain_model_version\' rows now');
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_terfe2_domain_model_version');
$queryBuilder
->getRestrictions()
->removeAll();
$queryBuilder
->select('uid', 'dependencies')
->from('tx_terfe2_domain_model_version');
$result = $queryBuilder->execute();
$itemsProcessed = 0;
while ($row = $result->fetchAssociative()) {
$dependencies = (string)($row['dependencies'] ?? '');
if ($dependencies === '' || strpos($dependencies, 'a:') === false) {
// skip already migrated or not serialized row
continue;
}
try {
$connectionPool
->getConnectionForTable('tx_terfe2_domain_model_version')
->update(
'tx_terfe2_domain_model_version',
['dependencies' => json_encode((array)(unserialize($dependencies, ['allowed_classes' => false]) ?: []), JSON_THROW_ON_ERROR)],
['uid' => $row['uid']]
);
$itemsProcessed++;
} catch (\JsonException $e) {
$io->error('Could not update record: \'' . $row['uid'] . '\'');
}
}
$io->success('Done. Updated ' . $itemsProcessed . ' items.');
return 0;
}
}
......@@ -161,7 +161,7 @@ class ExtensionIndexService implements LoggerAwareInterface
$this->xmlentities((string)$extensionVersionArr['upload_comment'])
)
);
$versionObj->appendChild(new \DOMElement('dependencies', (string)$extensionVersionArr['dependencies']));
$versionObj->appendChild(new \DOMElement('dependencies', $this->serializeDependencies($extensionVersionArr['dependencies'])));
$versionObj->appendChild(new \DOMElement('composerinfo', (string)$extensionVersionArr['composer_info']));
$versionObj->appendChild(new \DOMElement('authorname', $this->xmlentities((string)$extensionVersionArr['authorname'])));
$versionObj->appendChild(new \DOMElement('authoremail', $this->xmlentities((string)$extensionVersionArr['authoremail'])));
......@@ -230,4 +230,11 @@ class ExtensionIndexService implements LoggerAwareInterface
{
return GeneralUtility::makeInstance(Configuration::class)->getRepositoryBasePath();
}
protected function serializeDependencies(?string $dependencies): string
{
return $dependencies !== null
? (string)serialize(json_decode($dependencies, true))
: '';
}
}
......@@ -20,6 +20,9 @@ return [
'ter_fe2:addCompatibleTypo3Versions' => [
'class' => \T3o\TerFe2\Command\AddCompatibleTypo3Versions::class
],
'ter_fe2:migrateDependenciesToJson' => [
'class' => \T3o\TerFe2\Command\MigrateDependenciesToJson::class
],
'ter:createExtensionIndexXml' => [
'class' => \T3o\TerFe2\Command\CreateExtensionIndexCommand::class
],
......
......@@ -38,7 +38,7 @@ class ExtensionIndexServiceTest extends UnitTestCase
<downloadcounter/>
<lastuploaddate/>
<uploadcomment/>
<dependencies/>
<dependencies>a:1:{i:0;a:3:{s:4:"kind";s:7:"depends";s:12:"extensionKey";s:5:"typo3";s:12:"versionRange";s:13:"8.7.0-10.4.99";}}</dependencies>
<composerinfo/>
<authorname/>
<authoremail/>
......@@ -59,7 +59,7 @@ class ExtensionIndexServiceTest extends UnitTestCase
<downloadcounter/>
<lastuploaddate/>
<uploadcomment/>
<dependencies/>
<dependencies>a:0:{}</dependencies>
<composerinfo/>
<authorname/>
<authoremail/>
......@@ -68,6 +68,27 @@ class ExtensionIndexServiceTest extends UnitTestCase
<t3xfilemd5/>
<documentation_link/>
</version>
</extension>
<extension extensionkey="inc">
<downloadcounter>131313</downloadcounter>
<version version="2.0.0">
<title/>
<description/>
<state/>
<reviewstate/>
<category/>
<downloadcounter/>
<lastuploaddate/>
<uploadcomment/>
<dependencies/>
<composerinfo/>
<authorname/>
<authoremail/>
<authorcompany>INC</authorcompany>
<ownerusername>oli</ownerusername>
<t3xfilemd5/>
<documentation_link/>
</version>
</extension>
</extensions>
';
......@@ -79,6 +100,7 @@ class ExtensionIndexServiceTest extends UnitTestCase
'versions' => [
'1.0.0' => [
'authorcompany' => 'ACME',
'dependencies' => '[{"kind":"depends","extensionKey":"typo3","versionRange":"8.7.0-10.4.99"}]'
]
]
],
......@@ -87,7 +109,18 @@ class ExtensionIndexServiceTest extends UnitTestCase
'frontend_user' => 'david',
'versions' => [
'1.5.0' => [
'authorcompany' => 't3o'
'authorcompany' => 't3o',
'dependencies' => '[]'
]
]
],
'inc' => [
'downloads' => 131313,
'frontend_user' => 'oli',
'versions' => [
'2.0.0' => [
'authorcompany' => 'INC',
'dependencies' => null
]
]
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment