Project

General

Profile

Actions

Bug #17861

closed

Extension Manager does not sort versions of an extension correctly

Added by Micha Barthel almost 17 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extension Manager
Target version:
-
Start date:
2007-11-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

This list not sorted!
$versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
$latestVersion = end($versions);

On line: 1610,1735,1382......

User this sort Function from Elmar Hinz:

Own
------------------------------------------------
------------------------------------------------
Sort:
------------------------------------------------
usort($versions, array('SC_mod_tools_em_index', 'compare'));
------------------------------------------------
------------------------------------------------
Function:
------------------------------------------------
function compare($aIn, $bIn) {
$aParts = explode('.', $aIn, 2);
$bParts = explode('.', $bIn, 2);
$a = (int) $aParts0;
$b = (int) $bParts0;
if($a > $b){
return 1;
}elseif($a < $b){
return 1;
} else {
if(is_string($aParts1)) {
return SC_mod_tools_em_index::compare($aParts1, $bParts1);
} else {
return 0;
}
}
}
-----------------------------------------------

------------------------------------------------

regards Micha Barthel

(issue imported from #M6854)


Files

bug.txt (1.05 KB) bug.txt Administrator Admin, 2007-11-28 21:14
6854.diff (957 Bytes) 6854.diff Administrator Admin, 2010-05-14 01:27

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #22378: "Check for extension updates" does not always find latest versionClosedJeff Segars2010-04-05

Actions
Related to TYPO3 Core - Bug #22441: importExtInfo() does not sort versions correctlyClosedFrancois Suter2010-04-13

Actions
Actions #1

Updated by Benni Mack almost 17 years ago

can you give some examples what exactly the error is and why it is sorted?

Actions #2

Updated by Micha Barthel almost 17 years ago

There is a BUG when you like to get the current Ext Version ( see Ext: lab_newsfolders ),
but this is not by every Ext!
I had this problem with my t3s Extensions.....

Actions #3

Updated by Elmar Hinz almost 17 years ago

To say it in my words:

01. $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
02. $latestVersion = end($versions);

The function array_keys() does not garantee, that the array $versions is sorted in a proper way by versions. So it's a bug to simply call the end() function upon $versions. As a result $latestVersion does not always contain the latest version as expected.

Solution:

01. $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);

02. $this->sortVersions($versions);

03. $latestVersion = end($versions);

Micha has given an example how sortVersions() could look like:

usort($versions, array('SC_mod_tools_em_index', 'compare'));

etc.

Actions #4

Updated by Oliver Hader almost 17 years ago

I can confirm this. The current "sorting" is just the order of the entries of the xml file (http://typo3.org/fileadmin/ter/extensions.xml.gz). And this list isn't sorted correctly in all cases.

Elmar, your sort function looks good to me, just one annotation:
"if(is_string($aParts1)) {" should be "if (isset($aParts1) && isset($bParts1)) {"

Actions #5

Updated by Elmar Hinz almost 17 years ago

Remark:

The above sorting algorithm assumes that the latest version equals the highest version. That sounds natural on the first glance. But is it true?

Someone could have two branches for his extension: 2.x.x and 3.x.x.

While 3.3.3 would be the highest version 2.2.2 could still be the latest upload.

It depends on the context, what is really wanted.

Actions #6

Updated by Richard about 15 years ago

I can confirm that this bug is still present in 4.2.9. It took hours of my time to find out that the things in the manual didn't work because DAM 1.0.5 was installed as the latest DAM, although 1.1 is the latest version now.

Please integrate the solution as above. I think it is more useful to get the latest version below than the latest upload. In Elmar's example, where is the usefulness of the order 2.2.2, 3.3.3, 2.2.3, 3.3.4, 2.2.4 and later + 3.3.5 instead of 2.2.2, 2.2.3, 2.2.4, 3.3.4, 3.3.5 ? If you want to stay on 2.x, you can't use the latest upload anyway (because it could be a 3.x)

Actions #7

Updated by Chris topher over 14 years ago

The erroneous code has partly been fixed with the related bugs.
But there is still two occurences left:
One in installExtension() and one in importExtFromRep().

Actions #8

Updated by Lars Houmark over 14 years ago

I am working on a patch.

Christopher will you be able to test? I don't have a test case currently.

Actions #9

Updated by Lars Houmark over 14 years ago

Patch uploaded, and RFC posted to the core list. Now waiting for reviews, unless it is accepted as no-brainer.

@Christopher: If you (or others) have testcases, please either post them in the thread in the core list or email me them directly. Notice the BT mailer doesn't work atm, so I am unlikely to see a note here with a testcase.

Actions #10

Updated by Felix Kopp over 12 years ago

This issue can be closed.

Actions #11

Updated by Michael Stucki over 12 years ago

  • Status changed from Accepted to Resolved
  • Target version deleted (0)

Thanks Felix!

Actions #12

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF