[!!!][TASK] Support TYPO3 12.4 and PHP 8.1

Drop Support for TYPO3 v11 and other PHP versions.
This commit is contained in:
Daniel Siepmann 2023-10-25 08:28:18 +02:00
parent e4c52ff059
commit 1bd15f0259
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
11 changed files with 105 additions and 82 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
/Documentation-GENERATED-temp/
/.Build/
/vendor/
/composer.lock

View file

@ -17,6 +17,8 @@ declare(strict_types=1);
namespace FriendsOfTYPO3\LegacyCollections\Collection;
use TYPO3\CMS\Core\Collection\AbstractRecordCollection;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
@ -54,7 +56,7 @@ class RecordCollectionRepository
* Finds a record collection by uid.
*
* @param int $uid The uid to be looked up
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection|null
* @return AbstractRecordCollection|null
*/
public function findByUid($uid)
{
@ -70,9 +72,7 @@ class RecordCollectionRepository
}
$data = $queryBuilder->select('*')
->from($this->table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
->execute()
->from($this->table)->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))->executeQuery()
->fetch();
if (is_array($data)) {
$result = $this->createDomainObject($data);
@ -83,7 +83,7 @@ class RecordCollectionRepository
/**
* Finds all record collections.
*
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]|null
* @return AbstractRecordCollection[]|null
*/
public function findAll()
{
@ -94,7 +94,7 @@ class RecordCollectionRepository
* Finds record collections by table name.
*
* @param string $tableName Name of the table to be looked up
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]
* @return AbstractRecordCollection[]
*/
public function findByTableName($tableName)
{
@ -111,7 +111,7 @@ class RecordCollectionRepository
* Finds record collection by type.
*
* @param string $type Type to be looked up
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]|null
* @return AbstractRecordCollection[]|null
*/
public function findByType($type)
{
@ -129,7 +129,7 @@ class RecordCollectionRepository
*
* @param string $type Type to be looked up
* @param string $tableName Name of the table to be looked up
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]|null
* @return AbstractRecordCollection[]|null
*/
public function findByTypeAndTableName($type, $tableName)
{
@ -154,7 +154,7 @@ class RecordCollectionRepository
->getConnectionForTable($this->table)
->update(
$this->table,
['deleted' => 1, 'tstamp' => (int)$GLOBALS['EXEC_TIME']],
['deleted' => 1, 'tstamp' => (int)GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp')],
['uid' => (int)$uid]
);
}
@ -163,7 +163,7 @@ class RecordCollectionRepository
* Queries for multiple records for the given conditions.
*
* @param array $conditions Conditions concatenated with AND for query
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]|null
* @return AbstractRecordCollection[]|null
*/
protected function queryMultipleRecords(array $conditions = [])
{
@ -181,7 +181,7 @@ class RecordCollectionRepository
$queryBuilder->where(...$conditions);
}
$data = $queryBuilder->execute()->fetchAll();
$data = $queryBuilder->executeQuery()->fetchAll();
if (!empty($data)) {
$result = $this->createMultipleDomainObjects($data);
}
@ -193,7 +193,7 @@ class RecordCollectionRepository
* Creates a record collection domain object.
*
* @param array $record Database record to be reconstituted
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection
* @return AbstractRecordCollection
* @throws \RuntimeException
*/
protected function createDomainObject(array $record)
@ -212,7 +212,7 @@ class RecordCollectionRepository
* Creates multiple record collection domain objects.
*
* @param array $data Array of multiple database records to be reconstituted
* @return \TYPO3\CMS\Core\Collection\AbstractRecordCollection[]
* @return AbstractRecordCollection[]
*/
protected function createMultipleDomainObjects(array $data)
{

View file

@ -194,7 +194,7 @@ class StaticRecordCollection extends AbstractRecordCollection implements Editabl
)
)
->orderBy('sys_collection_entries.sorting')
->execute();
->executeQuery();
$relatedRecords = [];
while ($record = $statement->fetch()) {
$relatedRecords[] = $record;

View file

@ -5,7 +5,6 @@ return [
'label' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'descriptionColumn' => 'description',
'versioningWS' => true,
'origUid' => 't3_origuid',
@ -34,21 +33,7 @@ return [
'sys_language_uid' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'items' => [
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0]
],
'default' => 0,
'fieldWizard' => [
'selectIcons' => [
'disabled' => false,
],
],
]
'config' => ['type' => 'language']
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
@ -57,7 +42,7 @@ return [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0]
['label' => '', 'value' => 0]
],
'foreign_table' => 'sys_file_collection',
'foreign_table_where' => 'AND sys_file_collection.pid=###CURRENT_PID### AND sys_file_collection.sys_language_uid IN (-1,0)'
@ -78,7 +63,7 @@ return [
'default' => 0,
'items' => [
[
0 => '',
'label' => '',
1 => '',
'invertStateDisplay' => true
]
@ -89,9 +74,7 @@ return [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'date,int',
'type' => 'datetime',
'default' => 0,
]
],
@ -99,9 +82,7 @@ return [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'date,int',
'type' => 'datetime',
'default' => 0,
'range' => [
'upper' => mktime(0, 0, 0, 1, 1, 2038),
@ -115,10 +96,10 @@ return [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hide_at_login', -1],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.any_login', -2],
['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.usergroups', '--div--']
['label' => '', 'value' => 0],
['label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hide_at_login', 'value' => -1],
['label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.any_login', 'value' => -2],
['label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.usergroups', 'value' => '--div--']
],
'foreign_table' => 'fe_groups'
]
@ -135,7 +116,6 @@ return [
'label' => 'LLL:EXT:legacy_collections/Resources/Private/Language/locallang_tca.xlf:sys_collection.items',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'prepend_tname' => true,
'allowed' => '*',
'MM' => 'sys_collection_entries',
@ -149,7 +129,7 @@ return [
'config' => [
'type' => 'input',
'size' => 60,
'eval' => 'required'
'required' => true
]
],
'description' => [
@ -166,7 +146,7 @@ return [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['LLL:EXT:legacy_collections/Resources/Private/Language/locallang_tca.xlf:sys_collection.type.static', 'static']
['label' => 'LLL:EXT:legacy_collections/Resources/Private/Language/locallang_tca.xlf:sys_collection.type.static', 'value' => 'static']
],
'default' => 'static'
]

View file

@ -1,5 +0,0 @@
<?php
return [
'TYPO3\\CMS\\Core\\Collection\\StaticRecordCollection' => \FriendsOfTYPO3\LegacyCollections\Collection\StaticRecordCollection::class,
'TYPO3\\CMS\\Core\\Collection\\RecordCollectionRepository' => \FriendsOfTYPO3\LegacyCollections\Collection\RecordCollectionRepository::class,
];

View file

@ -17,6 +17,7 @@ declare(strict_types=1);
namespace FriendsOfTYPO3\LegacyCollections\Tests\Functional\Collection;
use PHPUnit\Framework\MockObject\MockObject;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use FriendsOfTYPO3\LegacyCollections\Collection\RecordCollectionRepository;
@ -31,8 +32,12 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class RecordCollectionRepositoryTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = [
'typo3conf/ext/legacy_collections',
];
/**
* @var RecordCollectionRepository|\PHPUnit\Framework\MockObject\MockObject
* @var RecordCollectionRepository|MockObject
*/
protected $subject;
@ -49,7 +54,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
parent::setUp();
$this->subject = $this->getMockBuilder(RecordCollectionRepository::class)
->setMethods(['getEnvironmentMode'])
->onlyMethods(['getEnvironmentMode'])
->getMock();
$this->testTableName = StringUtility::getUniqueId('tx_testtable');
}
@ -66,7 +71,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTypeReturnNull()
public function doesFindByTypeReturnNull(): void
{
$type = RecordCollectionRepository::TYPE_Static;
$objects = $this->subject->findByType($type);
@ -76,7 +81,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTypeReturnObjects()
public function doesFindByTypeReturnObjects(): void
{
$type = RecordCollectionRepository::TYPE_Static;
$this->insertTestData([
@ -93,7 +98,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTableNameReturnNull()
public function doesFindByTableNameReturnNull(): void
{
$objects = $this->subject->findByTableName($this->testTableName);
self::assertNull($objects);
@ -102,7 +107,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTableNameReturnObjects()
public function doesFindByTableNameReturnObjects(): void
{
$type = RecordCollectionRepository::TYPE_Static;
$this->insertTestData([
@ -119,7 +124,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTypeAndTableNameReturnNull()
public function doesFindByTypeAndTableNameReturnNull(): void
{
$type = RecordCollectionRepository::TYPE_Static;
$objects = $this->subject->findByTypeAndTableName($type, $this->testTableName);
@ -130,7 +135,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByTypeAndTableNameReturnObjects()
public function doesFindByTypeAndTableNameReturnObjects(): void
{
$type = RecordCollectionRepository::TYPE_Static;
$this->insertTestData([
@ -147,7 +152,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByUidReturnAnObjectInBackendMode()
public function doesFindByUidReturnAnObjectInBackendMode(): void
{
$this->subject->method('getEnvironmentMode')->willReturn('BE');
$type = RecordCollectionRepository::TYPE_Static;
@ -170,7 +175,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByUidRespectDeletedFieldInBackendMode()
public function doesFindByUidRespectDeletedFieldInBackendMode(): void
{
$this->subject->method('getEnvironmentMode')->willReturn('BE');
$type = RecordCollectionRepository::TYPE_Static;
@ -193,7 +198,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByUidIgnoreOtherEnableFieldsInBackendMode()
public function doesFindByUidIgnoreOtherEnableFieldsInBackendMode(): void
{
$this->subject->method('getEnvironmentMode')->willReturn('BE');
$type = RecordCollectionRepository::TYPE_Static;
@ -229,7 +234,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByUidReturnAnObjectInFrontendMode()
public function doesFindByUidReturnAnObjectInFrontendMode(): void
{
$this->subject->method('getEnvironmentMode')->willReturn('FE');
$type = RecordCollectionRepository::TYPE_Static;
@ -252,7 +257,7 @@ class RecordCollectionRepositoryTest extends FunctionalTestCase
/**
* @test
*/
public function doesFindByUidRespectEnableFieldsInFrontendMode()
public function doesFindByUidRespectEnableFieldsInFrontendMode(): void
{
$this->subject->method('getEnvironmentMode')->willReturn('FE');
$type = RecordCollectionRepository::TYPE_Static;

View file

@ -0,0 +1,3 @@
be_users
,uid,pid,username,password,admin
,1,0,admin,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,1,1
1 be_users
2 ,uid,pid,username,password,admin
3 ,1,0,admin,$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1,1,1

View file

@ -18,12 +18,16 @@ declare(strict_types=1);
namespace FriendsOfTYPO3\LegacyCollections\Tests\Functional\Tca;
use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class CollectionVisibleFieldsTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = [
'typo3conf/ext/legacy_collections',
];
protected static $collectionFields = [
'title',
'sys_language_uid',
@ -39,12 +43,13 @@ class CollectionVisibleFieldsTest extends FunctionalTestCase
/**
* @test
*/
public function collectionFormContainsExpectedFields()
public function collectionFormContainsExpectedFields(): void
{
$this->setUpBackendUserFromFixture(1);
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
$this->importCSVDataSet(__DIR__ . '/../Fixtures/BackendUser.csv');
$this->setUpBackendUser(1);
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('en_EN');
$formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
$formEngineTestService = new FormTestService();
$formResult = $formEngineTestService->createNewRecordForm('sys_collection');
foreach (static::$collectionFields as $expectedField) {

View file

@ -10,21 +10,18 @@
},
"license": ["GPL-2.0+"],
"require": {
"php": "^7.2 || ^8.0",
"typo3/cms-core": "^10.0 || ^11.5",
"typo3/cms-frontend": "^10.0 || ^11.5"
"php": "8.1.*",
"typo3/cms-core": "^12.4",
"typo3/cms-frontend": "^12.4"
},
"require-dev": {
"typo3/testing-framework": "^6.3.2"
"typo3/testing-framework": "^8.0"
},
"extra": {
"typo3/class-alias-loader": {
"class-alias-maps": [
"Migrations/Code/ClassAliasMap.php"
]
},
"typo3/cms": {
"extension-key": "legacy_collections"
"extension-key": "legacy_collections",
"app-dir": ".Build",
"web-dir": ".Build/Web"
}
},
"autoload": {
@ -34,7 +31,17 @@
},
"autoload-dev": {
"psr-4": {
"FriendsOfTYPO3\\LegacyCollections\\Tests\\": "Tests/"
"FriendsOfTYPO3\\LegacyCollections\\Tests\\": "Tests/",
"TYPO3\\CMS\\Backend\\Tests\\": "vendor/typo3/cms-backend/Tests/"
}
},
"config": {
"preferred-install": {
"typo3/cms-backend": "source"
},
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true
}
}
}

View file

@ -9,11 +9,11 @@ $EM_CONF[$_EXTKEY] = [
'author' => 'Benni Mack',
'author_email' => 'benni@typo3.org',
'author_company' => '',
'version' => '1.0.1',
'version' => '2.0.0',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
'frontend' => '10.4.0-11.5.99',
'typo3' => '12.4.0-12.4.99',
'frontend' => '12.4.0-12.4.99',
],
'conflicts' => [],
'suggests' => [],

25
phpunit.xml.dist Normal file
View file

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
requireCoverageMetadata="false"
>
<testsuites>
<testsuite name="functional">
<directory>Tests/Functional/</directory>
</testsuite>
</testsuites>
<php>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>
</phpunit>