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

[BUGFIX] Ignore non-typo3 packages in PackageState #519

Merged
merged 1 commit into from
Nov 22, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions Classes/Core/PackageCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\TestingFramework\Composer\ComposerPackageManager;

/**
* Collection for extension packages to resolve their dependencies in a test-base.
Expand All @@ -45,23 +46,28 @@ class PackageCollection
protected array $packages;

/**
* @param ComposerPackageManager $composerPackageManager
* @param PackageManager $packageManager
* @param array<PackageKey, StateConfiguration> $packageStates
*/
public static function fromPackageStates(PackageManager $packageManager, string $basePath, array $packageStates): self
public static function fromPackageStates(ComposerPackageManager $composerPackageManager, PackageManager $packageManager, string $basePath, array $packageStates): self
{
$packages = [];
foreach ($packageStates as $packageKey => $packageStateConfiguration) {
$packagePath = PathUtility::sanitizeTrailingSeparator(
rtrim($basePath, '/') . '/' . $packageStateConfiguration['packagePath']
);
$packages[] = new Package($packageManager, $packageKey, $packagePath);
$packages[] = $package = new Package($packageManager, $packageKey, $packagePath);
$packageManager->registerPackage($package);
}
return new self(...$packages);

return new self($composerPackageManager, ...$packages);
}

public function __construct(PackageInterface ...$packages)
{
public function __construct(
private ComposerPackageManager $composerPackageManager,
PackageInterface ...$packages,
) {
$this->packages = array_combine(
array_map(static fn(PackageInterface $package) => $package->getPackageKey(), $packages),
$packages
Expand Down Expand Up @@ -253,6 +259,11 @@ protected function getDependencyArrayForPackage(PackageInterface $package, array
$dependentPackageKeys[] = $dependentPackageKey;
}
if (!isset($this->packages[$dependentPackageKey])) {
if ($this->isComposerDependency($dependentPackageKey)) {
// The given package has a dependency to a Composer package that has no relation to TYPO3
// We can ignore those, when calculating the extension order
continue;
}
throw new Exception(
sprintf(
'Package "%s" depends on package "%s" which does not exist.',
Expand Down Expand Up @@ -305,6 +316,7 @@ protected function findFrameworkKeys(): array

protected function isComposerDependency(string $packageKey): bool
{
return false;
$packageInfo = $this->composerPackageManager->getPackageInfo($packageKey);
return !(($packageInfo?->isSystemExtension() ?? false) || ($packageInfo?->isExtension()));
}
}
3 changes: 2 additions & 1 deletion Classes/Core/Testbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ public function setUpPackageStates(
);
// PackageManager is required to create a Package instance...
$packageCollection = PackageCollection::fromPackageStates(
$this->composerPackageManager,
$packageManager,
$instancePath,
$packageStates['packages']
$packageStates['packages'],
);
$packageStates['packages'] = $packageCollection->sortPackageStates(
$packageStates['packages'],
Expand Down