Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
extensions.typo3.org
extensions.typo3.org
Commits
db9d8328
Commit
db9d8328
authored
Nov 02, 2020
by
Oliver Bartsch
Browse files
[TASK] Add command to migrate dependencies to JSON
parent
70202684
Pipeline
#9848
failed with stages
in 2 minutes and 41 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extensions/ter/Classes/Api/ExtensionVersion.php
View file @
db9d8328
...
...
@@ -545,8 +545,8 @@ class ExtensionVersion
'software_relations'
=>
0
,
't3x_file_size'
=>
@
filesize
(
$t3xFile
),
'zip_file_size'
=>
0
,
'composer_info'
=>
json_encode
(
$composerInfo
),
'dependencies'
=>
(
string
)
serializ
e
(
$dependenciesArr
),
'composer_info'
=>
json_encode
(
$composerInfo
)
?:
''
,
'dependencies'
=>
json_encod
e
(
$dependenciesArr
)
?:
''
,
'authorname'
=>
(
string
)
$extensionInfoData
->
metaData
->
authorName
,
'authoremail'
=>
(
string
)
$extensionInfoData
->
metaData
->
authorEmail
,
'authorcompany'
=>
(
string
)
$extensionInfoData
->
metaData
->
authorCompany
,
...
...
extensions/ter_fe2/Classes/Command/MigrateDependenciesToJson.php
0 → 100644
View file @
db9d8328
<?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
);
$queryBuilderForDetails
=
$connectionPool
->
getQueryBuilderForTable
(
'tx_terfe2_domain_model_version'
);
$queryBuilderForDetails
->
getRestrictions
()
->
removeAll
();
$statement
=
$queryBuilderForDetails
->
select
(
'uid'
,
'dependencies'
)
->
from
(
'tx_terfe2_domain_model_version'
)
->
execute
();
$itemsProcessed
=
0
;
while
(
$row
=
$statement
->
fetchAssociative
())
{
$dependencies
=
(
string
)(
$row
[
'dependencies'
]
??
''
);
if
(
$dependencies
===
''
||
strpos
(
$dependencies
,
'a:'
)
===
false
)
{
// skip already migrated or not serialized row
continue
;
}
try
{
GeneralUtility
::
makeInstance
(
ConnectionPool
::
class
)
->
getConnectionForTable
(
'tx_terfe2_domain_model_version'
)
->
update
(
'tx_terfe2_domain_model_version'
,
[
'dependencies'
=>
json_encode
((
array
)(
unserialize
(
$dependencies
,
[
self
::
class
])
?:
[]),
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
;
}
}
extensions/ter_fe2/Configuration/Commands.php
View file @
db9d8328
...
...
@@ -17,6 +17,9 @@ return [
'ter_fe2:fetchTranslationStatus'
=>
[
'class'
=>
\
T3o\TerFe2\Command\FetchTranslationStatusCommand
::
class
],
'ter_fe2:migrateDependenciesToJson'
=>
[
'class'
=>
\
T3o\TerFe2\Command\MigrateDependenciesToJson
::
class
],
'ter:createExtensionIndexXml'
=>
[
'class'
=>
\
T3o\TerFe2\Command\CreateExtensionIndexCommand
::
class
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment