Skip to content
Snippets Groups Projects
Commit 5b1d98db authored by Alexander Opitz's avatar Alexander Opitz Committed by Markus Klein
Browse files

[BUGFIX] EM: Update extension versions not in TER

The EM finds now extension updates for extension versions which aren't
in TER data.

Resolves: #65341
Releases: master, 6.2
Change-Id: Ia8c280f85b9c9f903334437bc059fad841c760da
Reviewed-on: http://review.typo3.org/37236


Reviewed-by: default avatarNicole Cordes <typo3@cordes.co>
Tested-by: default avatarNicole Cordes <typo3@cordes.co>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Tested-by: default avatarMarkus Klein <klein.t3@reelworx.at>
parent e2ffce60
No related merge requests found
......@@ -15,7 +15,10 @@ namespace TYPO3\CMS\Extensionmanager\Utility;
*/
use TYPO3\CMS\Core\Package\PackageInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
/**
* Utility for dealing with extension list related functions
......@@ -70,7 +73,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
$extensions = array();
foreach ($this->packageManager->getAvailablePackages() as $package) {
// Only TYPO3 related packages could be handled by the extension manager
// Composer packages from "Packages" folder will be instanciated as \TYPO3\Flow\Package\Package
// Composer packages from "Packages" folder will be instantiated as \TYPO3\Flow\Package\Package
if (!($package instanceof \TYPO3\CMS\Core\Package\PackageInterface)) {
continue;
}
......@@ -79,7 +82,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
'siteRelPath' => str_replace(PATH_site, '', $package->getPackagePath()),
'type' => $installationType,
'key' => $package->getPackageKey(),
'ext_icon' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon($package->getPackagePath()),
'ext_icon' => ExtensionManagementUtility::getExtensionIcon($package->getPackagePath()),
);
}
return $extensions;
......@@ -99,7 +102,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
* @return string
*/
protected function getInstallTypeForPackage(PackageInterface $package) {
foreach (\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnInstallPaths() as $installType => $installPath) {
foreach (Extension::returnInstallPaths() as $installType => $installPath) {
if (GeneralUtility::isFirstPartOfStr($package->getPackagePath(), $installPath)) {
return $installType;
}
......@@ -133,8 +136,8 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
$emconf = $this->emConfUtility->includeEmConf($properties);
if ($emconf) {
$extensions[$extensionKey] = array_merge($emconf, $properties);
$terObject = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $extensions[$extensionKey]['version']);
if ($terObject instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
$terObject = $this->getExtensionTerData($extensionKey, $extensions[$extensionKey]['version']);
if ($terObject !== NULL) {
$extensions[$extensionKey]['terObject'] = $terObject;
$extensions[$extensionKey]['updateAvailable'] = $this->installUtility->isUpdateAvailable($terObject);
$extensions[$extensionKey]['updateToVersion'] = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
......@@ -146,6 +149,36 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
return $extensions;
}
/**
* Tries to find given extension with given version in TER data.
* If extension is found but not the given version, we return TER data from highest version with version data set to
* given one.
*
* @param string $extensionKey Key of the extension
* @param string $version String representation of version number
* @return Extension|NULL Extension TER object or NULL if nothing found
*/
protected function getExtensionTerData($extensionKey, $version) {
$terObject = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $version);
if (!$terObject instanceof Extension) {
// Version unknown in TER data, try to find extension
$terObject = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
if ($terObject instanceof Extension) {
// Found in TER now, set version information to the known ones, so we can look if there is a newer one
// Use a cloned object, otherwise wrong information is stored in persistenceManager
$terObject = clone $terObject;
$terObject->setVersion($version);
$terObject->setIntegerVersion(
VersionNumberUtility::convertVersionNumberToInteger($terObject->getVersion())
);
} else {
$terObject = NULL;
}
}
return $terObject;
}
/**
* Adds information about icon size to the extension information
*
......
......@@ -171,7 +171,7 @@ class ListUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
* @return void
*/
public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
$this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, array('findOneByExtensionKeyAndVersion'), array(), '', FALSE));
$this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, array('findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'), array(), '', FALSE));
$emConfUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class);
$emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
$this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
......
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