Skip to content
GitLab
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
f056aa8d
Commit
f056aa8d
authored
Dec 29, 2021
by
Thomas Löffler
Browse files
[TASK] Remove migration commands which are used one-time
parent
9bf6f24a
Pipeline
#21492
passed with stages
in 6 minutes and 8 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extensions/ter_fe2/Classes/Command/AddCompatibleTypo3Versions.php
deleted
100644 → 0
View file @
9bf6f24a
<?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\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Style\SymfonyStyle
;
use
T3o\TerFe2\Utility\VersionUtility
;
use
TYPO3\CMS\Core\Database\ConnectionPool
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
/**
* One time command, can be removed in late 2020.
*/
class
AddCompatibleTypo3Versions
extends
Command
{
protected
function
configure
():
void
{
$this
->
setDescription
(
'One-time-migration. Adds tx_terfe2_domain_model_version.compatible_typo3_versions from dependencies data.'
)
->
addOption
(
'skipNonEmptyFields'
,
null
,
InputOption
::
VALUE_OPTIONAL
,
'If command is used a second time, skip already migrated fields.'
,
false
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
):
int
{
$io
=
new
SymfonyStyle
(
$input
,
$output
);
$skipNonEmptyFields
=
(
bool
)
$input
->
getOption
(
'skipNonEmptyFields'
);
$connectionPool
=
GeneralUtility
::
makeInstance
(
ConnectionPool
::
class
);
$queryBuilder
=
$connectionPool
->
getQueryBuilderForTable
(
'tx_terfe2_domain_model_version'
);
$io
->
section
(
'Updating field \'compatible_typo3_versions\' of all \'tx_terfe2_domain_model_version\' rows now'
);
$io
->
warning
(
'Please make sure, the new column \'compatible_typo3_versions\' exists.'
);
$queryBuilder
->
getRestrictions
()
->
removeAll
();
$queryBuilder
->
select
(
'uid'
,
'dependencies'
)
->
from
(
'tx_terfe2_domain_model_version'
);
if
(
$skipNonEmptyFields
)
{
$io
->
writeln
(
'<info>Rows with non empty fields are skipped.</info>'
);
$queryBuilder
->
where
(
$queryBuilder
->
expr
()
->
isNull
(
'compatible_typo3_versions'
)
);
}
$result
=
$queryBuilder
->
execute
();
$itemsProcessed
=
0
;
while
(
$row
=
$result
->
fetchAssociative
())
{
// First check if the data is still in old serialized format
$dependencies
=
(
array
)(
unserialize
((
string
)(
$row
[
'dependencies'
]
??
''
),
[
'allowed_classes'
=>
false
])
?:
[]);
if
(
$dependencies
===
[])
{
// Fallback for the new JSON format
try
{
$dependencies
=
(
array
)(
json_decode
((
string
)(
$row
[
'dependencies'
]
??
''
),
true
,
512
,
JSON_THROW_ON_ERROR
)
?:
[]);
if
(
$dependencies
===
[])
{
// If still empty move on with next row
continue
;
}
}
catch
(
\
JsonException
$e
)
{
continue
;
}
}
$compatibleTypo3Versions
=
VersionUtility
::
getCompatibleTypo3Versions
(
$dependencies
);
if
(
$compatibleTypo3Versions
===
''
)
{
continue
;
}
$connectionPool
->
getConnectionForTable
(
'tx_terfe2_domain_model_version'
)
->
update
(
'tx_terfe2_domain_model_version'
,
[
'compatible_typo3_versions'
=>
$compatibleTypo3Versions
],
[
'uid'
=>
$row
[
'uid'
]]
);
$itemsProcessed
++
;
}
$io
->
success
(
'Done. Updated '
.
$itemsProcessed
.
' items.'
);
return
0
;
}
}
extensions/ter_fe2/Classes/Command/MigrateDependenciesToJson.php
deleted
100644 → 0
View file @
9bf6f24a
<?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
;
}
}
extensions/ter_fe2/Configuration/Commands.php
View file @
f056aa8d
...
...
@@ -17,12 +17,6 @@ return [
'ter_fe2:fetchTranslationStatus'
=>
[
'class'
=>
\
T3o\TerFe2\Command\FetchTranslationStatusCommand
::
class
],
'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
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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