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

[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
{
/**
* TODO: Do we still need this?
* @var \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected $databaseConnection;
......
......@@ -15,6 +15,8 @@ namespace T3o\TerFe2\Controller;
*/
use T3o\TerFe2\Validation\Validator\ComposerNameValidator;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Controller for the extension object
......@@ -579,23 +581,28 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
/**
* 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
* @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 : []);
if (empty($this->frontendUser['username'])) {
return false;
}
$isAllowedToUploadKey = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensionkeys');
$isAllowedToUploadKey = $connection->count(
'uid',
'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);
}
......@@ -614,24 +621,31 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
/**
* 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 $versionString The extension version
* @return bool TRUE if version already exists
*
* TODO: Discuss with Thomas, logic looks incorrect with naming and return value.
*/
protected function versionIsPossibleForExtension($extensionKey, $versionString)
{
if (empty($extensionKey) || empty($versionString)) {
return false;
}
$versionExistsForExtension = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensions');
$versionExistsForExtension = $connection->count(
'uid',
'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
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
*
......
......@@ -14,6 +14,8 @@ namespace T3o\TerFe2\Provider;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Abstract extension provider
*/
......@@ -123,7 +125,7 @@ abstract class AbstractProvider implements \T3o\TerFe2\Provider\ProviderInterfac
*/
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);
$maximum = (!empty($version[1]) ? \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($version[1]) : 0);
......
......@@ -219,7 +219,7 @@ class MirrorService implements \TYPO3\CMS\Core\SingletonInterface
$url = \T3o\TerFe2\Utility\FileUtility::getAbsolutePathFromUrl($url);
$content = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($url);
} 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)) {
......
......@@ -14,6 +14,13 @@ namespace T3o\TerFe2\Task;
* 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
* to the new ter_fe2 tables.
......@@ -31,6 +38,24 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
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
*
......@@ -38,6 +63,7 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
public function execute()
{
$this->extensionRepository = $this->objectManager->get(RepositoryRepository::class);
$extensionKeysFromTer = $this->getAllExtensionKeysFromTer();
foreach ($extensionKeysFromTer as $extensionData) {
......@@ -59,31 +85,35 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
public function getAllExtensionKeysFromTer(): array
{
$extData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*',
'tx_ter_extensionkeys',
'',
false,
'crdate'
$extData = [];
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_ter_extensionkeys');
$result = $connection->select(
['*'],
'tx_ter_extensionkeys'
);
while ($row = $result->fetch()) {
$extData[] = $row;
}
return $extData;
}
/**
* @param array $extData
*
* @return int $uid extension uid
* @return bool|int
* @deprecated Will be removed June 2020
*/
public function extensionExists($extData)
{
$extRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
'uid',
'tx_terfe2_domain_model_extension',
'NOT deleted AND ext_key = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($extData['extensionkey'], 'tx_terfe2_domain_model_extension')
);
$extensionRepository = $this->objectManager->get(ExtensionRepository::class);
$extension = $extensionRepository->findOneByExtKey($extData['extensionkey']);
return !empty($extRec);
if ($extension instanceof Extension) {
return $extension->getUid();
}
return false;
}
/**
......@@ -92,13 +122,8 @@ class ImportAllExtensionKeysTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
public function getVersionCount($extensionKey)
{
$versionCounter = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
'uid',
'tx_ter_extensions',
'extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($extensionKey, 'tx_ter_extensions')
);
return (int)$versionCounter;
$extensionRepository = $this->objectManager->get(ExtensionRepository::class);
return $extensionRepository->countByExtKey($extensionKey);
}
/**
......@@ -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) . ';
} elseif (strlen($k)) {
$lines .= str_repeat(TAB, $level) . "'" . $k . "' => "
. (\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 [
'enablecolumns' => [
'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' => [
'showRecordFieldList' => 'name,email,company,forge_link,username,versions,frontend_user,author_type',
......
......@@ -16,7 +16,7 @@ return [
'enablecolumns' => [
'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' => [
'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 [
'enablecolumns' => [
'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' => [
'showRecordFieldList' => 'relation_type,relation_key,minimum_version,maximum_version',
......
......@@ -16,7 +16,7 @@ return [
'enablecolumns' => [
'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' => [
'showRecordFieldList' => 'title,extensions',
......
......@@ -18,7 +18,7 @@ return [
'enablecolumns' => [
'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' => [
'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 () {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
mod.wizards.newContentElement.wizardItems.special {\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
description = LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xlf:newContentElement.wizardItem.description\n\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