Commit 2f73fc49 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen Committed by Thomas Löffler
Browse files

[TASK] Remove breaking changes for ter_fe2

parent 0ba8ea4a
Pipeline #7442 passed with stages
in 2 minutes and 52 seconds
...@@ -24,6 +24,7 @@ class ExtensionController ...@@ -24,6 +24,7 @@ class ExtensionController
{ {
/** /**
* TODO: Do we still need this?
* @var \TYPO3\CMS\Core\Database\DatabaseConnection * @var \TYPO3\CMS\Core\Database\DatabaseConnection
*/ */
protected $databaseConnection; protected $databaseConnection;
......
...@@ -15,6 +15,8 @@ namespace T3o\TerFe2\Controller; ...@@ -15,6 +15,8 @@ namespace T3o\TerFe2\Controller;
*/ */
use T3o\TerFe2\Validation\Validator\ComposerNameValidator; use T3o\TerFe2\Validation\Validator\ComposerNameValidator;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Controller for the extension object * Controller for the extension object
...@@ -579,23 +581,28 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController ...@@ -579,23 +581,28 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
/** /**
* Check if current frontend user can upload given extension * Check if current frontend user can upload given extension
* *
* There is no better (and faster) way to do this at the momement. * There is no better (and faster) way to do this at the moment.
* *
* @param string $extensionKey The extension key * @param string $extensionKey The extension key
* @return bool TRUE if upload is allowed * @return bool TRUE if upload is allowed
*/ */
protected function userIsAllowedToUploadExtension($extensionKey) protected function userIsAllowedToUploadExtension($extensionKey): bool
{ {
$this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : []); $this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : []);
if (empty($this->frontendUser['username'])) { if (empty($this->frontendUser['username'])) {
return false; return false;
} }
$isAllowedToUploadKey = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensionkeys');
$isAllowedToUploadKey = $connection->count(
'uid', 'uid',
'tx_ter_extensionkeys', 'tx_ter_extensionkeys',
'ownerusername LIKE "' . $GLOBALS['TYPO3_DB']->quoteStr($this->frontendUser['username'], 'foo') . '" [
AND extensionkey LIKE "' . $GLOBALS['TYPO3_DB']->quoteStr($extensionKey, 'foo') . '"' 'ownerusername' => $this->frontendUser['username'],
'extensionkey' => $extensionKey
]
); );
return !empty($isAllowedToUploadKey); return !empty($isAllowedToUploadKey);
} }
...@@ -614,24 +621,31 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController ...@@ -614,24 +621,31 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
/** /**
* Check if an version does not exist for extension * Check if an version does not exist for extension
* *
* There is no better (and faster) way to do this at the momement. * There is no better (and faster) way to do this at the moment.
* *
* @param string $extensionKey The extension key * @param string $extensionKey The extension key
* @param string $versionString The extension version * @param string $versionString The extension version
* @return bool TRUE if version already exists * @return bool TRUE if version already exists
*
* TODO: Discuss with Thomas, logic looks incorrect with naming and return value.
*/ */
protected function versionIsPossibleForExtension($extensionKey, $versionString) protected function versionIsPossibleForExtension($extensionKey, $versionString)
{ {
if (empty($extensionKey) || empty($versionString)) { if (empty($extensionKey) || empty($versionString)) {
return false; return false;
} }
$versionExistsForExtension = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensions');
$versionExistsForExtension = $connection->count(
'uid', 'uid',
'tx_ter_extensions', 'tx_ter_extensions',
'extensionkey = "' . $GLOBALS['TYPO3_DB']->quoteStr($extensionKey, 'foo') . '" [
AND version LIKE "' . $GLOBALS['TYPO3_DB']->quoteStr($versionString, 'foo') . '"' 'extensionkey' => $extensionKey,
'version' => $versionString
]
); );
return empty($versionExistsForExtension);
return $versionExistsForExtension;
} }
/** /**
......
...@@ -107,6 +107,19 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito ...@@ -107,6 +107,19 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
return $query->execute()->getFirst(); return $query->execute()->getFirst();
} }
/**
* Returns extension by extension key
*
* @param $extensionKey
* @return int
*/
public function countByExtKey($extensionKey)
{
$query = $this->createQuery(0, 1);
$this->match($query, $query->equals('extKey', $extensionKey));
return $query->execute()->count();
}
/** /**
* Returns new and updated extensions * Returns new and updated extensions
* *
......
...@@ -14,6 +14,8 @@ namespace T3o\TerFe2\Provider; ...@@ -14,6 +14,8 @@ namespace T3o\TerFe2\Provider;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Abstract extension provider * Abstract extension provider
*/ */
...@@ -123,7 +125,7 @@ abstract class AbstractProvider implements \T3o\TerFe2\Provider\ProviderInterfac ...@@ -123,7 +125,7 @@ abstract class AbstractProvider implements \T3o\TerFe2\Provider\ProviderInterfac
*/ */
protected function getVersionByRange($version) protected function getVersionByRange($version)
{ {
$version = \TYPO3\CMS\Extbase\Utility\ArrayUtility::trimExplode('-', $version); $version = GeneralUtility::trimExplode('-', $version);
$minimum = (!empty($version[0]) ? \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($version[0]) : 0); $minimum = (!empty($version[0]) ? \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($version[0]) : 0);
$maximum = (!empty($version[1]) ? \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($version[1]) : 0); $maximum = (!empty($version[1]) ? \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($version[1]) : 0);
......
...@@ -219,7 +219,7 @@ class MirrorService implements \TYPO3\CMS\Core\SingletonInterface ...@@ -219,7 +219,7 @@ class MirrorService implements \TYPO3\CMS\Core\SingletonInterface
$url = \T3o\TerFe2\Utility\FileUtility::getAbsolutePathFromUrl($url); $url = \T3o\TerFe2\Utility\FileUtility::getAbsolutePathFromUrl($url);
$content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url); $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url);
} else { } else {
$content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url, 0, [TYPO3_user_agent]); $content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url, 0, $GLOBALS['TYPO3_CONF_VARS']['HTTP']['headers']['User-Agent']);
} }
if (empty($content)) { if (empty($content)) {
......
...@@ -14,6 +14,13 @@ namespace T3o\TerFe2\Task; ...@@ -14,6 +14,13 @@ namespace T3o\TerFe2\Task;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use T3o\TerFe2\Domain\Model\Extension;
use T3o\TerFe2\Domain\Repository\ExtensionRepository;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository;
/** /**
* This is a one-time task to get all extension keys from ter tables * This is a one-time task to get all extension keys from ter tables
* to the new ter_fe2 tables. * to the new ter_fe2 tables.
...@@ -31,6 +38,24 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -31,6 +38,24 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/ */
protected $pid = 2; protected $pid = 2;
/**
* @var ObjectManager
*/
protected $objectManager;
/**
* @var ExtensionRepository
*/
protected $extensionRepository;
/**
* @param ObjectManager $objectManager
*/
protected function injectObjectManager(ObjectManager $objectManager)
{
$this->objectManager = $objectManager;
}
/** /**
* executes the importer * executes the importer
* *
...@@ -38,6 +63,7 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -38,6 +63,7 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/ */
public function execute() public function execute()
{ {
$this->extensionRepository = $this->objectManager->get(RepositoryRepository::class);
$extensionKeysFromTer = $this->getAllExtensionKeysFromTer(); $extensionKeysFromTer = $this->getAllExtensionKeysFromTer();
foreach ($extensionKeysFromTer as $extensionData) { foreach ($extensionKeysFromTer as $extensionData) {
...@@ -59,31 +85,35 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -59,31 +85,35 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/ */
public function getAllExtensionKeysFromTer(): array public function getAllExtensionKeysFromTer(): array
{ {
$extData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( $extData = [];
'*', $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensionkeys');
'tx_ter_extensionkeys', $result = $connection->select(
'', ['*'],
false, 'tx_ter_extensionkeys'
'crdate'
); );
while ($row = $result->fetch()) {
$extData[] = $row;
}
return $extData; return $extData;
} }
/** /**
* @param array $extData * @param array $extData
* * @return bool|int
* @return int $uid extension uid * @deprecated Will be removed June 2020
*/ */
public function extensionExists($extData) public function extensionExists($extData)
{ {
$extRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow( $extensionRepository = $this->objectManager->get(ExtensionRepository::class);
'uid', $extension = $extensionRepository->findOneByExtKey($extData['extensionkey']);
'tx_terfe2_domain_model_extension',
'NOT deleted AND ext_key = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($extData['extensionkey'], 'tx_terfe2_domain_model_extension')
);
return !empty($extRec); if ($extension instanceof Extension) {
return $extension->getUid();
}
return false;
} }
/** /**
...@@ -92,13 +122,8 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -92,13 +122,8 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/ */
public function getVersionCount($extensionKey) public function getVersionCount($extensionKey)
{ {
$versionCounter = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows( $extensionRepository = $this->objectManager->get(ExtensionRepository::class);
'uid', return $extensionRepository->countByExtKey($extensionKey);
'tx_ter_extensions',
'extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($extensionKey, 'tx_ter_extensions')
);
return (int)$versionCounter;
} }
/** /**
...@@ -118,6 +143,10 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -118,6 +143,10 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
]; ];
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_terfe2_domain_model_extension', $insertExtension); $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_terfe2_domain_model_extension');
$connection->insert(
'tx_terfe2_domain_model_extension',
$insertExtension
);
} }
} }
...@@ -520,7 +520,7 @@ $EM_CONF[$_EXTKEY] = ' . self::arrayToCode($emConfArray, 0) . '; ...@@ -520,7 +520,7 @@ $EM_CONF[$_EXTKEY] = ' . self::arrayToCode($emConfArray, 0) . ';
} elseif (strlen($k)) { } elseif (strlen($k)) {
$lines .= str_repeat(TAB, $level) . "'" . $k . "' => " $lines .= str_repeat(TAB, $level) . "'" . $k . "' => "
. (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($v) ? intval($v) : "'" . (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($v) ? intval($v) : "'"
. \TYPO3\CMS\Core\Utility\GeneralUtility::slashJS(trim($v), 1) . "'") . ',' . LF; . str_replace('\\', '\\\\', trim($v))) . ',' . LF;
} }
} }
......
...@@ -16,7 +16,7 @@ return [ ...@@ -16,7 +16,7 @@ return [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Icons/author.gif', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Icons/author.gif',
], ],
'interface' => [ 'interface' => [
'showRecordFieldList' => 'name,email,company,forge_link,username,versions,frontend_user,author_type', 'showRecordFieldList' => 'name,email,company,forge_link,username,versions,frontend_user,author_type',
......
...@@ -16,7 +16,7 @@ return [ ...@@ -16,7 +16,7 @@ return [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Icons/extension.gif', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Icons/extension.gif',
], ],
'interface' => [ 'interface' => [
'showRecordFieldList' => 'ext_key,forge_link,last_update,last_maintained,tags,versions,last_version,frontend_user,downloads,composer_name,repository_url,paypal_url,external_manual,expire', 'showRecordFieldList' => 'ext_key,forge_link,last_update,last_maintained,tags,versions,last_version,frontend_user,downloads,composer_name,repository_url,paypal_url,external_manual,expire',
......
...@@ -16,7 +16,7 @@ return [ ...@@ -16,7 +16,7 @@ return [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Icons/relation.gif', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Icons/relation.gif',
], ],
'interface' => [ 'interface' => [
'showRecordFieldList' => 'relation_type,relation_key,minimum_version,maximum_version', 'showRecordFieldList' => 'relation_type,relation_key,minimum_version,maximum_version',
......
...@@ -16,7 +16,7 @@ return [ ...@@ -16,7 +16,7 @@ return [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Icons/tag.gif', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Icons/tag.gif',
], ],
'interface' => [ 'interface' => [
'showRecordFieldList' => 'title,extensions', 'showRecordFieldList' => 'title,extensions',
......
...@@ -18,7 +18,7 @@ return [ ...@@ -18,7 +18,7 @@ return [
'enablecolumns' => [ 'enablecolumns' => [
'disabled' => 'hidden' 'disabled' => 'hidden'
], ],
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Icons/version.gif', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Icons/version.gif',
], ],
'interface' => [ 'interface' => [
'showRecordFieldList' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,has_manual,software_relations,author,file_hash,extension_provider,has_zip_file,has_images,composer_info', 'showRecordFieldList' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,has_manual,software_relations,author,file_hash,extension_provider,has_zip_file,has_images,composer_info',
......
...@@ -30,7 +30,7 @@ call_user_func(function () { ...@@ -30,7 +30,7 @@ call_user_func(function () {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(' \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
mod.wizards.newContentElement.wizardItems.special {\n mod.wizards.newContentElement.wizardItems.special {\n
elements.' . $extIdent . ' {\n elements.' . $extIdent . ' {\n
icon = ' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('ter_fe2') . 'Resources/Public/Images/Wizard.gif\n icon = ' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('ter_fe2') . 'Resources/Public/Images/Wizard.gif\n
title = LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xlf:newContentElement.wizardItem.title\n title = LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xlf:newContentElement.wizardItem.title\n
description = LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xlf:newContentElement.wizardItem.description\n\n description = LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xlf:newContentElement.wizardItem.description\n\n
tt_content_defValues {\n tt_content_defValues {\n
......
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