Bug #17861

Extension Manager does not sort versions of an extension correctly

Added by Micha Barthel almost 14 years ago. Updated about 3 years ago.

Should have
Extension Manager
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


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:

usort($versions, array('SC_mod_tools_em_index', 'compare'));
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)


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

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

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


Updated by Benni Mack almost 14 years ago

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


Updated by Micha Barthel almost 14 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.....


Updated by Elmar Hinz almost 14 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.


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'));



Updated by Oliver Hader almost 14 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)) {"


Updated by Elmar Hinz almost 14 years ago


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.


Updated by Richard about 12 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)


Updated by Chris topher over 11 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().


Updated by Lars Houmark over 11 years ago

I am working on a patch.

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


Updated by Lars Houmark over 11 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.


Updated by Felix Kopp about 9 years ago

This issue can be closed.


Updated by Michael Stucki about 9 years ago

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

Thanks Felix!


Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF