Commit d3e2cf38 authored by Thomas Löffler's avatar Thomas Löffler

[BUGFIX] Changes API and helper class to run in 8 LTS with an ext upload

parent 7f117713
Pipeline #1778 passed with stages
in 2 minutes and 54 seconds
......@@ -169,7 +169,7 @@ class tx_ter_api
);
}
if (($typo3DependencyCheck = $this->checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)) !== true && $uploadUserRecordArr['admin'] !== true) {
if (($typo3DependencyCheck = static::checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)) !== true && $uploadUserRecordArr['admin'] !== true) {
switch ($typo3DependencyCheck) {
case TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYINCORRECT:
$message = 'Extension does not have a dependency for a supported version of TYPO3. See http://typo3.org/news/article/announcing-ter-cleanup-process/ for how to fix this.';
......@@ -224,12 +224,12 @@ class tx_ter_api
// Make an instance of the api
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ter']);
$dummyParentObject = (object)[
'cObj' => GeneralUtility::makeInstance('tslib_cObj'),
'cObj' => GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class),
'extensionsPID' => $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ter_pi1.']['pid'],
'repositoryDir' => $extConf['repositoryDir'],
'conf' => $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ter_pi1.'],
];
$instance = GeneralUtility::makeInstance('tx_ter_api', $dummyParentObject);
$instance = GeneralUtility::makeInstance(\tx_ter_api::class, $dummyParentObject);
$accountData = (object)['username' => $username];
// Load extension
$extensionKeyRecordArr = $instance->helperObj->getExtensionKeyRecord(strtolower($extensionInfoData->extensionKey));
......@@ -249,7 +249,7 @@ class tx_ter_api
);
}
if (($typo3DependencyCheck = self::checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)) !== true) {
if (($typo3DependencyCheck = static::checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)) !== true) {
switch ($typo3DependencyCheck) {
case TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYINCORRECT:
$message = 'Extension does not have a dependency for a supported version of TYPO3. See http://typo3.org/news/article/announcing-ter-cleanup-process/ for how to fix this.';
......@@ -1114,7 +1114,7 @@ class tx_ter_api
*
* @return bool|integer True if success, error code in case of failure
*/
protected function checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)
protected static function checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)
{
$result = TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYCHECKFAILED;
$coreVersionData = GeneralUtility::getUrl(
......@@ -1122,13 +1122,14 @@ class tx_ter_api
);
$currentCores = json_decode($coreVersionData, true);
if ($currentCores !== null) {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($currentCores);
$result = TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYINCORRECT;
// Collect currently supported core versions
$supportedCoreVersions = [];
$oldestSupportedCoreVersion = '99.99.99';
$newestCoreVersion = '0.0.0';
foreach ($currentCores as $version => $coreInfo) {
if ($coreInfo['active'] === true) {
if (is_array($coreInfo) && $coreInfo['active'] === true) {
// Only use keys that represent a branch number
if (strpos($version, '.') && preg_match('/^(\d+)\.\d+$/', $version, $matches)) {
$latestBranchVersion = $coreInfo['latest'];
......@@ -1519,7 +1520,6 @@ class tx_ter_api
// Load environment
if (empty($this->tce)) {
$this->helperObj->loadBackendUser(1, '_ter_', true);
$GLOBALS['TSFE']->includeTCA();
$this->helperObj->loadLang();
$this->loadTceForm();
}
......
......@@ -240,18 +240,15 @@ class tx_ter_helper
*/
public function getExtensionKeyRecord($extKey)
{
global $TYPO3_DB, $TSFE;
$res = $TYPO3_DB->exec_SELECTquery(
'*', 'tx_ter_extensionkeys', 'extensionkey=' . $TYPO3_DB->fullQuoteStr($extKey, 'tx_ter_extensionkeys') . '
AND pid=' . intval($this->pluginObj->extensionsPID) . $TSFE->sys_page->enableFields('tx_ter_extensionkeys')
$row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'*',
'tx_ter_extensionkeys',
'extensionkey=' . $this->getDatabaseConnection()->fullQuoteStr($extKey, 'tx_ter_extensionkeys') .
'AND pid=' . intval($this->pluginObj->extensionsPID) .
$this->getTyposcriptFrontendObject()->sys_page->enableFields('tx_ter_extensionkeys')
);
if ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
return $row;
}
return false;
return $row;
}
/**
......@@ -510,4 +507,20 @@ class tx_ter_helper
$GLOBALS['LANG'] = GeneralUtility::makeInstance('language');
$GLOBALS['LANG']->init($lang);
}
/**
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
private function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
/**
* @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
*/
private function getTyposcriptFrontendObject()
{
return $GLOBALS['TSFE'];
}
}
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