Skip to content

Commit a3d4c21

Browse files
committed
[WIP][TASK] ext_emconf.php deprecation free functional tests
1 parent bc918e4 commit a3d4c21

3 files changed

Lines changed: 70 additions & 8 deletions

File tree

Classes/Composer/ComposerPackageManager.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
use Composer\InstalledVersions;
21+
use TYPO3\CMS\Core\Information\Typo3Version;
2122
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
2223

2324
/**
@@ -166,9 +167,17 @@ private function processRootPackage(): void
166167
$packageRealPath = $this->realPath($packagePath);
167168
$info = $this->getPackageComposerJson($packagePath);
168169
$packageType = $info['type'] ?? '';
169-
$extEmConf = $this->getExtEmConf($packagePath);
170+
$extEmConf = null;
171+
if ((new Typo3Version())->getMajorVersion() >= 14) {
172+
if (isset($info['extra']['typo3/cms']['Package']['providesPackages'])) {
173+
$extEmConf = null;
174+
} else {
175+
$extEmConf = $this->getExtEmConf($packagePath);
176+
}
177+
} else {
178+
$extEmConf = $this->getExtEmConf($packagePath);
179+
}
170180
$extensionKey = $this->determineExtensionKey($packagePath, $info, $extEmConf);
171-
172181
$packageInfo = new PackageInfo(
173182
$packageName,
174183
$packageType,
@@ -253,6 +262,12 @@ private function getPackageFromPath(string $path): ?PackageInfo
253262
}
254263
$info = $this->getPackageComposerJson($path);
255264
$extEmConf = $this->getExtEmConf($path);
265+
// Remove ext_emconf for TYPO3 v14
266+
if ((new Typo3Version())->getMajorVersion() >= 14
267+
&& isset($info['extra']['typo3/cms']['Package']['providesPackages'])
268+
) {
269+
$extEmConf = null;
270+
}
256271
$extensionKey = $this->determineExtensionKey($path, $info, $extEmConf);
257272
$packageName = $info['name'] ?? $this->normalizePackageName($extensionKey);
258273
$packageType = $info['type'] ?? ($extEmConf !== null ? 'typo3-cms-extension' : '');
@@ -262,13 +277,20 @@ private function getPackageFromPath(string $path): ?PackageInfo
262277
if ($packageInfo = $this->getPackageInfo($extensionKey)) {
263278
return $packageInfo;
264279
}
280+
$version = $info['version'] ?? $extEmConf['version'] ?? null;
281+
// System extensions in TYPO3 mono-repository are exactly the same version as the root package. Use it.
282+
$version ??= ($this->rootPackage()->isMonoRepository()) ? $this->rootPackage()->getVersion() : null;
283+
// If root package is a typo3 extension use the root package version assuming that we handle a fixture ext
284+
$version ??= ($this->rootPackage()->isExtension()) ? $this->rootPackage()->getVersion() : null;
285+
// Use root package version, falling back to COMPOSER_ROOT_VERSION and hard coded `1.0.0` as last fallback
286+
$version ??= $this->rootPackage()->getVersion() ?: getenv('COMPOSER_ROOT_VERSION') ?: '1.0.0';
265287
$packageInfo = new PackageInfo(
266288
$packageName,
267289
$packageType,
268290
$path,
269291
$this->realPath($path),
270292
// System extensions in mono-repository are exactly the same version as the root package. Use it.
271-
$this->rootPackage()->getVersion(),
293+
$version,
272294
$extensionKey,
273295
$info,
274296
$extEmConf,
@@ -297,7 +319,14 @@ private function processMonoRepository(): void
297319
$packageName = $info['name'] ?? '';
298320
$packageType = $info['type'] ?? '';
299321
$extEmConf = $this->getExtEmConf($packageRealPath);
322+
// Remove ext_emconf for TYPO3 v14
323+
if ((new Typo3Version())->getMajorVersion() >= 14
324+
&& isset($info['extra']['typo3/cms']['Package']['providesPackages'])
325+
) {
326+
$extEmConf = null;
327+
}
300328
$extensionKey = $this->determineExtensionKey($packageRealPath, $info, $extEmConf);
329+
$version = null;
301330
$packageInfo = new PackageInfo(
302331
$packageName,
303332
$packageType,
@@ -332,15 +361,22 @@ private function processPackages(): void
332361
$packagePath = $this->getPackageInstallPath($packageName);
333362
$packageRealPath = $this->realPath($packagePath);
334363
$info = $this->getPackageComposerJson($packagePath);
335-
$extEmConf = $this->getExtEmConf($packagePath);
364+
$extEmConf = null;
365+
if ((new Typo3Version())->getMajorVersion() >= 14) {
366+
if (!isset($info['extra']['typo3/cms']['Package']['providesPackages'])) {
367+
$extEmConf = $this->getExtEmConf($packagePath);
368+
}
369+
} else {
370+
$extEmConf = $this->getExtEmConf($packagePath);
371+
}
336372
$packageType = $info['type'] ?? '';
337373
$extensionKey = $this->determineExtensionKey($packagePath, $info, $extEmConf);
338374
$this->addPackageInfo(new PackageInfo(
339375
$packageName,
340376
$packageType,
341377
$packagePath,
342378
$packageRealPath,
343-
(string)($version['pretty_version'] ?? $this->prettifyVersion($extEmConf['version'] ?? '')),
379+
(string)($version['pretty_version'] ?? $this->prettifyVersion($extEmConf['version'] ?? '1.0.0')),
344380
$extensionKey,
345381
$info,
346382
$extEmConf

Classes/Core/PackageCollection.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace TYPO3\TestingFramework\Core;
1919

20+
use TYPO3\CMS\Core\Information\Typo3Version;
2021
use TYPO3\CMS\Core\Package\MetaData;
2122
use TYPO3\CMS\Core\Package\MetaData\PackageConstraint;
2223
use TYPO3\CMS\Core\Package\Package;
@@ -89,7 +90,26 @@ public static function fromPackageStates(ComposerPackageManager $composerPackage
8990
$packagePath = PathUtility::sanitizeTrailingSeparator(
9091
rtrim($basePath, '/') . '/' . $packageStateConfiguration['packagePath']
9192
);
92-
$packages[] = $package = new Package($packageManager, $packageKey, $packagePath);
93+
$info = $composerPackageManager->getPackageInfo($packageKey);
94+
if ((new Typo3Version())->getMajorVersion() >= 14) {
95+
$packages[] = $package = new Package(
96+
$packageManager,
97+
$packageKey,
98+
$packagePath,
99+
// Load package as it is in classic mode
100+
false,
101+
// Emulate to have a version in `composer.json` to mitigate depreation, but throw
102+
// it in case it's not there and `ext_emconf.php` will be loaded.
103+
$info?->getVersion() ?: null,
104+
);
105+
} else {
106+
// @todo Remove when TYPO3 v13 support is dropped.
107+
$packages[] = $package = new Package(
108+
$packageManager,
109+
$packageKey,
110+
$packagePath,
111+
);
112+
}
93113
$packageManager->registerPackage($package);
94114
}
95115

Classes/Core/Testbase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
use Psr\Container\ContainerInterface;
2828
use TYPO3\CMS\Core\Core\Bootstrap;
2929
use TYPO3\CMS\Core\Core\ClassLoadingInformation;
30+
use TYPO3\CMS\Core\Core\Environment;
3031
use TYPO3\CMS\Core\Database\Connection;
3132
use TYPO3\CMS\Core\Database\ConnectionPool;
3233
use TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory;
3334
use TYPO3\CMS\Core\Database\Schema\SchemaMigrator;
3435
use TYPO3\CMS\Core\Database\Schema\SqlReader;
36+
use TYPO3\CMS\Core\Package\Cache\PackageStatesPackageCache;
3537
use TYPO3\CMS\Core\Package\PackageManager;
3638
use TYPO3\CMS\Core\Service\DependencyOrderingService;
3739
use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -598,6 +600,8 @@ public function setUpPackageStates(
598600
array $testExtensionPaths,
599601
array $frameworkExtensionPaths
600602
): void {
603+
@mkdir($instancePath . '/typo3conf', 0775, true);
604+
$packagesStateFile = $instancePath . '/typo3conf/PackageStates.php';
601605
$packageStates = [
602606
'packages' => [],
603607
'version' => 5,
@@ -643,10 +647,12 @@ public function setUpPackageStates(
643647
];
644648
}
645649

650+
$coreCache = Bootstrap::createCache('core');
651+
$packageCache = new PackageStatesPackageCache($packagesStateFile, $coreCache);
646652
$dependencyOrderingService = new DependencyOrderingService();
647653
$packageManager = new PackageManager(
648654
$dependencyOrderingService,
649-
$instancePath . '/typo3conf/PackageStates.php',
655+
$packagesStateFile,
650656
$instancePath
651657
);
652658
// PackageManager is required to create a Package instance...
@@ -662,7 +668,7 @@ public function setUpPackageStates(
662668
);
663669

664670
$result = file_put_contents(
665-
$instancePath . '/typo3conf/PackageStates.php',
671+
$packagesStateFile,
666672
'<?php' . chr(10) .
667673
'return ' .
668674
ArrayUtility::arrayExport(

0 commit comments

Comments
 (0)