-
Notifications
You must be signed in to change notification settings - Fork 23
Test Service for latest secure TYPO3 core #76
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,8 @@ public static function updateLatestTypo3VersionRegistry() | |
|
||
$max = array(); | ||
$stable = array(); | ||
$security = array(); | ||
$latestLts = $releases['latest_lts']; | ||
foreach ($releases as $major => $details) { | ||
if (is_array($details) && !empty($details['latest'])) { | ||
$max[$major] = $details['latest']; | ||
|
@@ -75,10 +77,40 @@ public static function updateLatestTypo3VersionRegistry() | |
if (is_array($details) && !empty($details['stable'])) { | ||
$stable[$major] = $details['stable']; | ||
} | ||
if (is_array($details) && is_array($details['releases'])) { | ||
$found = false; | ||
$latestCheckedVersion = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. Not necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
foreach ($details['releases'] as $version => $versionDetails) { | ||
$latestCheckedVersion = $version; | ||
// if major version > latest_lts check if bugfix part of version number == '0'; | ||
// in that case this is the security update and stop searching | ||
if (version_compare($major, $latestLts, '>')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the fist version in releases always the one to choose for $major > $lts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the intention of checking $major > $latestLts at all? |
||
if ($versionDetails['type'] === 'security') { | ||
$security[$major] = $version; | ||
$found = true; | ||
break; | ||
} | ||
// if versionDetails->type === 'security' then this is the security update; stop searching | ||
if (self::extractBugfixNumberFromVersion($version) === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why you don't use \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionStringToArray? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
$security[$major] = $version; | ||
$found = true; | ||
break; | ||
} | ||
// if versionDetails->type === 'security' then this is the security update; stop searching | ||
} elseif ($versionDetails['type'] === 'security') { | ||
$security[$major] = $version; | ||
$found = true; | ||
break; | ||
} | ||
} | ||
if (!$found) { | ||
$security[$major] = $latestCheckedVersion; | ||
} | ||
} | ||
} | ||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Registry')->set('tx_caretaker', 'TYPO3versions', $max); | ||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Registry')->set('tx_caretaker', 'TYPO3versionsStable', $stable); | ||
|
||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Registry')->set('tx_caretaker', 'TYPO3versionsSecurity', $security); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please split these three lines. First get the registry object, then use it to store all three information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
return true; | ||
} | ||
|
||
|
@@ -113,4 +145,19 @@ protected static function curlRequest($requestUrl = false) | |
|
||
return $response; | ||
} | ||
|
||
/** | ||
* extracts the bugfix part of a version number | ||
* | ||
* @param string $version | ||
* @return integer | ||
*/ | ||
protected static function extractBugfixNumberFromVersion($version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this is not needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
{ | ||
$version = str_replace(array('_', ',', '-', '+'), '.', $version); | ||
$version = preg_replace('/(\d)([^\d\.])/', '$1.$2', $version); | ||
$version = preg_replace('/([^\d\.])(\d)/', '$1.$2', $version); | ||
$versionParts = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode('.', $version, true, 3); | ||
return $versionParts[2]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not necessary. Just set $security[$major] to the latest before the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅