Commit 3c31fb47 authored by Andreas Wolf's avatar Andreas Wolf
Browse files

Merge branch...

Merge branch '180-let-typo3-cms-releases-go-green-if-supported-by-any-version-of-the-extension' into 'develop'

Checks every version of extension for LTS support

Closes #180

See merge request t3o/ter!291
parents fcdcaa87 53284da6
Pipeline #3079 failed with stages
in 5 minutes and 13 seconds
......@@ -245,7 +245,7 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for versions
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version> Versions
* @return Version[]|\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Version>
*/
public function getVersions(): ObjectStorage
{
......
......@@ -1168,9 +1168,25 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$supportedTypo3Versions = [];
foreach ($typo3Versions as $label => $mainVersion) {
$supportedTypo3Versions[$label] = \T3o\TerFe2\Utility\VersionUtility::doesExtensionVersionSupportTypo3Version($this, $mainVersion);
$supportedTypo3Versions[$label] = \T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $mainVersion);
}
return $supportedTypo3Versions;
}
/**
* @return bool
*/
public function hasTypo3Dependency()
{
return $this->getTypo3Dependency() !== null;
}
/**
* @return bool
*/
public function isLive()
{
return $this->getReviewState() >= 0;
}
}
......@@ -103,15 +103,16 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer
// does this extension supports different versions?
// @todo: use JSON with all versions to get them
$lastVersion = $extension->getLastVersion();
$document->setField('supports7_boolS', VersionUtility::doesExtensionVersionSupportTypo3Version($lastVersion, 7006000));
$document->setField('supports8_boolS', VersionUtility::doesExtensionVersionSupportTypo3Version($lastVersion, 8007000));
$document->setField('supports7_boolS', false);
$document->setField('supports8_boolS', false);
$typo3Support = [];
if (VersionUtility::doesExtensionVersionSupportTypo3Version($lastVersion, 7006000)) {
if (VersionUtility::doesExtensionSupportTypo3Version($extension, 7006000)) {
$typo3Support[] = '7 LTS';
$document->setField('supports7_boolS', true);
}
if (VersionUtility::doesExtensionVersionSupportTypo3Version($lastVersion, 8007000)) {
if (VersionUtility::doesExtensionSupportTypo3Version($extension, 8007000)) {
$typo3Support[] = '8 LTS';
$document->setField('supports8_boolS', true);
}
$document->setField('typo3support_stringM', $typo3Support);
......
......@@ -42,19 +42,27 @@ class VersionUtility
}
/**
* @param \T3o\TerFe2\Domain\Model\Version $version
* @param \T3o\TerFe2\Domain\Model\Extension $extension
* @param int $mainVersion
* @return bool
*/
public static function doesExtensionVersionSupportTypo3Version(\T3o\TerFe2\Domain\Model\Version $version, int $mainVersion): bool
public static function doesExtensionSupportTypo3Version(\T3o\TerFe2\Domain\Model\Extension $extension, int $mainVersion): bool
{
if (empty($version->getTypo3Dependency())) {
return false;
}
foreach ($extension->getVersions() as $version) {
if ($version->hasTypo3Dependency() === false || $version->isLive() === false) {
continue;
}
// reset from e.g. 7.6.21 to 7.6.0 for valid check
$resetMinimumVersion = (int)($version->getTypo3Dependency()->getMinimumVersion() / 1000) * 1000;
// reset from e.g. 7.6.21 to 7.6.0 for valid check
$resetMinimumVersion = (int)($version->getTypo3Dependency()->getMinimumVersion() / 1000) * 1000;
$supportsTypo3Version = $resetMinimumVersion <= $mainVersion && $version->getTypo3Dependency()->getMaximumVersion() >= $mainVersion;
if ($supportsTypo3Version) {
return true;
}
}
return $resetMinimumVersion <= $mainVersion && $version->getTypo3Dependency()->getMaximumVersion() >= $mainVersion;
return false;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment