Commit 5025247c authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

Set the last_version only if version_number is higher than the previous one

parent 8328b257
Pipeline #2545 passed with stages
in 2 minutes and 4 seconds
......@@ -275,10 +275,12 @@ class ImportExtensionsFromQueueTask extends Task
*/
public function updateExtension($versionUid, $extUid)
{
$highestVersionUid = $this->calculatedHighestVersion($versionUid, $extUid);
$updateExtension = [
'tstamp' => time(),
'versions' => $this->getNumberOfVersions($extUid),
'last_version' => $versionUid
'last_version' => $highestVersionUid
];
$this->getDatabaseConnection()->exec_UPDATEquery(
'tx_terfe2_domain_model_extension',
......@@ -449,4 +451,70 @@ class ImportExtensionsFromQueueTask extends Task
{
return $GLOBALS['TYPO3_DB'];
}
/**
* Check which version is higher, so that we can se the right version in latest_version
*
* @param $versionUid
* @param $extUid
* @return mixed
*/
private function calculatedHighestVersion($versionUid, $extUid): mixed
{
$currentHighestVersion = $this->getHighestVersion($extUid);
if (empty($currentHighestVersion)) {
return $versionUid;
}
$newVersionNumber = $this->getVersionNumber($versionUid);
if (!$newVersionNumber > $currentHighestVersion['version_number']) {
$versionUid = $currentHighestVersion['uid'];
}
return $versionUid;
}
/**
* Get the version number of the current version
*
* @param $versionUid
* @return int
*/
private function getVersionNumber($versionUid)
{
$res = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'version_number',
'tx_terfe2_domain_model_version',
'uid = ' . $versionUid . ' AND NOT deleted'
);
if ($res['version_number']) {
return $res['version_number'];
}
return 0;
}
/**
* Gets the highest version number
*
* @param $extUid
*
* @return array|FALSE|NULL
*/
private function getHighestVersion($extUid) {
$res = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'uid,version_number',
'tx_terfe2_domain_model_version',
'extension = ' . $extUid . ' AND NOT deleted',
'',
'ORDER BY version_number DESC'
);
if (!empty($res)) {
return $res;
}
return [];
}
}
Markdown is supported
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