[BUGFIX] Prevent current extension version in update dialog 11/43811/2
authorNicole Cordes <typo3@cordes.co>
Thu, 1 Oct 2015 12:25:17 +0000 (14:25 +0200)
committerNicole Cordes <typo3@cordes.co>
Mon, 5 Oct 2015 12:08:07 +0000 (14:08 +0200)
If you update an extension, the current version is included in the
confirmation dialog. This might confuse the user as this version is
already available. The patch re-adds the usage of the repository
function to exclude the current used version in the query.

Resolves: #65904
Releases: master, 6.2
Change-Id: I49aa2ba36bbfd7888aa202028dfd9e9c882a8183
Reviewed-on: http://review.typo3.org/43811
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
typo3/sysext/extensionmanager/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php

index 34a76bc..e11b5a3 100644 (file)
@@ -224,7 +224,8 @@ class DownloadController extends AbstractController {
                $updatableVersions = $this->extensionRepository->findByVersionRangeAndExtensionKeyOrderedByVersion(
                        $extensionKey,
                        $versionStart,
-                       $versionStop
+                       $versionStop,
+                       FALSE
                );
                $highestPossibleVersion = FALSE;
 
index 4b6515b..34efa0d 100644 (file)
@@ -167,17 +167,30 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         * @param string $extensionKey
         * @param integer $lowestVersion
         * @param integer $highestVersion
+        * @param bool $includeCurrentVersion
         * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
         */
-       public function findByVersionRangeAndExtensionKeyOrderedByVersion($extensionKey, $lowestVersion = 0, $highestVersion = 0) {
+       public function findByVersionRangeAndExtensionKeyOrderedByVersion($extensionKey, $lowestVersion = 0, $highestVersion = 0, $includeCurrentVersion = TRUE) {
                $query = $this->createQuery();
                $constraint = NULL;
                if ($lowestVersion !== 0 && $highestVersion !== 0) {
-                       $constraint = $query->logicalAnd($query->lessThanOrEqual('integerVersion', $highestVersion), $query->greaterThanOrEqual('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       if ($includeCurrentVersion) {
+                               $constraint = $query->logicalAnd($query->lessThanOrEqual('integerVersion', $highestVersion), $query->greaterThanOrEqual('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       } else {
+                               $constraint = $query->logicalAnd($query->lessThanOrEqual('integerVersion', $highestVersion), $query->greaterThan('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       }
                } elseif ($lowestVersion === 0 && $highestVersion !== 0) {
-                       $constraint = $query->logicalAnd($query->lessThanOrEqual('integerVersion', $highestVersion), $query->equals('extensionKey', $extensionKey));
+                       if ($includeCurrentVersion) {
+                               $constraint = $query->logicalAnd($query->lessThanOrEqual('integerVersion', $highestVersion), $query->equals('extensionKey', $extensionKey));
+                       } else {
+                               $constraint = $query->logicalAnd($query->lessThan('integerVersion', $highestVersion), $query->equals('extensionKey', $extensionKey));
+                       }
                } elseif ($lowestVersion !== 0 && $highestVersion === 0) {
-                       $constraint = $query->logicalAnd($query->greaterThanOrEqual('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       if ($includeCurrentVersion) {
+                               $constraint = $query->logicalAnd($query->greaterThanOrEqual('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       } else {
+                               $constraint = $query->logicalAnd($query->greaterThan('integerVersion', $lowestVersion), $query->equals('extensionKey', $extensionKey));
+                       }
                } elseif ($lowestVersion === 0 && $highestVersion === 0) {
                        $constraint = $query->equals('extensionKey', $extensionKey);
                }
index 1873f35..12f6804 100644 (file)
@@ -429,7 +429,9 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
                /** @var $extensionUpdates[] \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
                $extensionUpdates = $this->extensionRepository->findByVersionRangeAndExtensionKeyOrderedByVersion(
                        $extensionData->getExtensionKey(),
-                       $version + 1
+                       $version,
+                       0,
+                       FALSE
                );
                if ($extensionUpdates->count() > 0) {
                        foreach ($extensionUpdates as $extensionUpdate) {