Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Clean up run levels #792

Merged
merged 1 commit into from Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -69,16 +69,16 @@ jobs:
env: TYPO3_VERSION="~9.5.0"
- stage: test
php: 7.2
env: TYPO3_VERSION=^8.7.10
env: TYPO3_VERSION=^8.7.22
- stage: test
php: 7.1
env: TYPO3_VERSION=^8.7.10
env: TYPO3_VERSION=^8.7.22
- stage: test
php: 7.0
env: TYPO3_VERSION=^8.7.10
env: TYPO3_VERSION=^8.7.22
- stage: test
php: 7.0
env: TYPO3_VERSION=^8.7.10 PREFER_LOWEST="--prefer-lowest"
env: TYPO3_VERSION=^8.7.22 PREFER_LOWEST="--prefer-lowest"
- stage: test
php: 7.2
env: TYPO3_VERSION="dev-master"
Expand Down
29 changes: 1 addition & 28 deletions Classes/Console/Core/Booting/RunLevel.php
Expand Up @@ -20,7 +20,7 @@
class RunLevel
{
const LEVEL_ESSENTIAL = 'buildEssentialSequence';
const LEVEL_COMPILE = 'buildCompiletimeSequence';
const LEVEL_COMPILE = 'buildEssentialSequence';
const LEVEL_MINIMAL = 'buildBasicRuntimeSequence';
const LEVEL_FULL = 'buildExtendedRuntimeSequence';

Expand Down Expand Up @@ -212,20 +212,6 @@ private function buildEssentialSequence(string $identifier): Sequence
return $sequence;
}

/**
* Minimal usable system with most core caches disabled
*
* @return Sequence
*/
private function buildCompiletimeSequence(): Sequence
{
$sequence = $this->buildEssentialSequence(self::LEVEL_COMPILE);

$this->addStep($sequence, 'helhum.typo3console:loadextbaseconfiguration');

return $sequence;
}

/**
* System with complete configuration, but no database
*
Expand Down Expand Up @@ -293,19 +279,6 @@ private function addStep(Sequence $sequence, string $stepIdentifier)
$sequence->addStep(new Step($stepIdentifier, [Scripts::class, 'initializeErrorHandling']));
break;

// Part of compile time
case 'helhum.typo3console:loadextbaseconfiguration':
$this->executedSteps[$stepIdentifier] = self::LEVEL_COMPILE;
$sequence->addStep(new Step($stepIdentifier, function () {
// @deprecated in 5.5, will be removed in 6.0
// Requirement for the removal is converting all command controllers to Symfony commands
// and removing all usages of ObjectManager in our code, which is the reason we include
// this file early, to get the ObjectManager configured properly
unset($GLOBALS['TYPO3_LOADED_EXT']['extbase']['ext_localconf.php']);
require PATH_site . 'typo3/sysext/extbase/ext_localconf.php';
}));
break;

// Part of basic runtime
case 'helhum.typo3console:extensionconfiguration':
$this->executedSteps[$stepIdentifier] = self::LEVEL_MINIMAL;
Expand Down
13 changes: 12 additions & 1 deletion Classes/Console/Core/Booting/Scripts.php
Expand Up @@ -16,13 +16,18 @@

use Helhum\Typo3Console\Error\ErrorHandler;
use Helhum\Typo3Console\Error\ExceptionHandler;
use Helhum\Typo3Console\Property\TypeConverter\ArrayConverter;
use Symfony\Component\Console\Exception\RuntimeException;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Property\TypeConverter\BooleanConverter;
use TYPO3\CMS\Extbase\Property\TypeConverter\FloatConverter;
use TYPO3\CMS\Extbase\Property\TypeConverter\IntegerConverter;
use TYPO3\CMS\Extbase\Property\TypeConverter\StringConverter;

class Scripts
{
Expand Down Expand Up @@ -149,10 +154,16 @@ public static function provideCleanClassImplementations()
{
self::overrideImplementation(\TYPO3\CMS\Extbase\Command\HelpCommandController::class, \Helhum\Typo3Console\Command\HelpCommandController::class);
self::overrideImplementation(\TYPO3\CMS\Extbase\Mvc\Cli\Command::class, \Helhum\Typo3Console\Mvc\Cli\Command::class);

// @deprecated can be removed once command controller support is removed
if (empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be dropped when ExtensionUtility::registerTypeConverter() is used.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = [];
}
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = \Helhum\Typo3Console\Property\TypeConverter\ArrayConverter::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = ArrayConverter::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = StringConverter::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = BooleanConverter::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = IntegerConverter::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'][] = FloatConverter::class;
mbrodala marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
18 changes: 14 additions & 4 deletions Classes/Console/Core/Kernel.php
Expand Up @@ -160,10 +160,20 @@ public function handle(InputInterface $input): int
$application->setCommandLoader($commandCollection);

// Try to resolve short command names and aliases
$commandName = $commandCollection->find($input->getFirstArgument() ?: 'list');
if ($this->runLevel->isCommandAvailable($commandName)) {
$this->runLevel->runSequenceForCommand($commandName);
$commandCollection->addCommandControllerCommands($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'] ?? []);
$givenCommandName = $input->getFirstArgument() ?: 'list';
$commandNameCandidate = $commandCollection->find($givenCommandName);
if ($this->runLevel->isCommandAvailable($commandNameCandidate)) {
$this->runLevel->runSequenceForCommand($commandNameCandidate);
// @deprecated will be removed once command controller support is removed
if ($this->runLevel->getRunLevelForCommand($commandNameCandidate) !== RunLevel::LEVEL_ESSENTIAL) {
$commandCollection->addCommandControllerCommands($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'] ?? []);
$commandName = $commandCollection->find($givenCommandName);
if ($commandNameCandidate !== $commandName) {
// Mitigate #779 and #778 at least when command controller commands conflict with non low level
// previously registered commands
$this->runLevel->runSequenceForCommand($commandName);
}
}
}

return $application->run($input);
Expand Down
24 changes: 14 additions & 10 deletions Classes/Console/Property/TypeConverter/ArrayConverter.php
Expand Up @@ -14,6 +14,9 @@
*
*/

use TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException;
use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface;

/**
* Converter which transforms arrays to arrays.
*
Expand Down Expand Up @@ -44,7 +47,7 @@ class ArrayConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractT
/**
* @var int
*/
protected $priority = 2;
protected $priority = 15;

/**
* Convert from $source to $targetType, a noop if the source is an array.
Expand All @@ -53,11 +56,11 @@ class ArrayConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractT
* @param string|array $source
* @param string $targetType
* @param array $convertedChildProperties
* @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
* @param PropertyMappingConfigurationInterface $configuration
* @throws InvalidPropertyMappingConfigurationException
* @return array
* @api
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = [], \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): array
{
if (is_string($source)) {
if ($source === '') {
Expand All @@ -71,20 +74,21 @@ public function convertFrom($source, $targetType, array $convertedChildPropertie
}

/**
* @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
* @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException
* @param PropertyMappingConfigurationInterface $configuration
* @throws InvalidPropertyMappingConfigurationException
* @return string
*/
protected function getConfiguredStringDelimiter(\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
private function getConfiguredStringDelimiter(PropertyMappingConfigurationInterface $configuration = null): string
{
if ($configuration === null) {
return self::DEFAULT_STRING_DELIMITER;
}
$stringDelimiter = $configuration->getConfigurationValue(\Helhum\Typo3Console\Property\TypeConverter\ArrayConverter::class, self::CONFIGURATION_STRING_DELIMITER);
$stringDelimiter = $configuration->getConfigurationValue(self::class, self::CONFIGURATION_STRING_DELIMITER);
if ($stringDelimiter === null) {
return self::DEFAULT_STRING_DELIMITER;
} elseif (!is_string($stringDelimiter)) {
throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException('CONFIGURATION_STRING_DELIMITER must be of type string, "' . (is_object($stringDelimiter) ? get_class($stringDelimiter) : gettype($stringDelimiter)) . '" given', 1368433339);
}
if (!is_string($stringDelimiter)) {
throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_STRING_DELIMITER must be of type string, "' . (is_object($stringDelimiter) ? get_class($stringDelimiter) : gettype($stringDelimiter)) . '" given', 1368433339);
}

return $stringDelimiter;
Expand Down
12 changes: 6 additions & 6 deletions Resources/Private/ExtensionArtifacts/ext_emconf.php
Expand Up @@ -15,12 +15,12 @@
'constraints' => [
'depends' => [
'php' => '7.0.0-7.3.99',
'typo3' => '8.7.10-9.5.99',
'extbase' => '8.7.10-9.5.99',
'extensionmanager' => '8.7.10-9.5.99',
'fluid' => '8.7.10-9.5.99',
'install' => '8.7.10-9.5.99',
'scheduler' => '8.7.10-9.5.99',
'typo3' => '8.7.22-9.5.99',
'extbase' => '8.7.22-9.5.99',
'extensionmanager' => '8.7.22-9.5.99',
'fluid' => '8.7.22-9.5.99',
'install' => '8.7.22-9.5.99',
'scheduler' => '8.7.22-9.5.99',
],
'conflicts' => [
'dbal' => '',
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Expand Up @@ -35,24 +35,24 @@
"php": ">=7.0.0 <7.4",
"helhum/typo3-console-plugin": "^2.0.2",

"typo3/cms-backend": "~8.7.10 || ~9.5.0",
"typo3/cms-core": "~8.7.10 || ~9.5.0",
"typo3/cms-extbase": "~8.7.10 || ~9.5.0",
"typo3/cms-extensionmanager": "~8.7.10 || ~9.5.0",
"typo3/cms-fluid": "~8.7.10 || ~9.5.0",
"typo3/cms-frontend": "~8.7.10 || ~9.5.0",
"typo3/cms-install": "~8.7.10 || ~9.5.0",
"typo3/cms-backend": "~8.7.22 || ~9.5.0",
"typo3/cms-core": "~8.7.22 || ~9.5.0",
"typo3/cms-extbase": "~8.7.22 || ~9.5.0",
"typo3/cms-extensionmanager": "~8.7.22 || ~9.5.0",
"typo3/cms-fluid": "~8.7.22 || ~9.5.0",
"typo3/cms-frontend": "~8.7.22 || ~9.5.0",
"typo3/cms-install": "~8.7.22 || ~9.5.0",
"typo3/cms-saltedpasswords": "*",
"typo3/cms-scheduler": "~8.7.10 || ~9.5.0",
"typo3/cms-scheduler": "~8.7.22 || ~9.5.0",

"doctrine/annotations": "^1.4",
"symfony/console": "^3.4.4 || ^4.0",
"symfony/process": "^3.4.4 || ^4.0",
"helhum/config-loader": ">=0.9 <0.13"
},
"require-dev": {
"typo3/cms-reports": "~8.7.10 || ~9.5.0 || dev-master",
"typo3/cms-filemetadata": "~8.7.10 || ~9.5.0 || dev-master",
"typo3/cms-reports": "~8.7.22 || ~9.5.0 || dev-master",
"typo3/cms-filemetadata": "~8.7.22 || ~9.5.0 || dev-master",

"typo3-console/convert-command-controller-command": "@dev",
"typo3-console/create-reference-command": "@dev",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -24,7 +24,7 @@
<env name="TYPO3_INSTALL_WEB_SERVER_SETUP_TYPE" value="none" />
<env name="TYPO3_INSTALL_SITE_SETUP_TYPE" value="createsite" />
<env name="TYPO3_VERSION" value="~9.5.0" />
<env name="TYPO3_UPGRADE_FROM_VERSION" value="~8.7.10" />
<env name="TYPO3_UPGRADE_FROM_VERSION" value="~8.7.22" />
</php>
<testsuites>
<testsuite name="TYPO3 Console Unit Tests">
Expand Down