Skip to content

Commit 822b76c

Browse files
committed
Revert "[TASK] Introduce cache for SimpleTcaSchema"
This reverts commit a1d4f0d.
1 parent dcc9667 commit 822b76c

File tree

7 files changed

+48
-68
lines changed

7 files changed

+48
-68
lines changed

Classes/Schema/SimpleTcaSchemaFactory.php

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,31 @@
1717

1818
namespace TYPO3\CMS\ContentBlocks\Schema;
1919

20-
use Symfony\Component\DependencyInjection\Attribute\Autowire;
21-
use Symfony\Component\VarExporter\VarExporter;
2220
use TYPO3\CMS\ContentBlocks\Schema\Exception\UndefinedSchemaException;
2321
use TYPO3\CMS\ContentBlocks\Schema\Field\FieldCollection;
2422
use TYPO3\CMS\ContentBlocks\Schema\Field\TcaField;
25-
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
2623
use TYPO3\CMS\Core\SingletonInterface;
2724

2825
/**
2926
* @internal Not part of TYPO3's public API.
3027
*/
3128
class SimpleTcaSchemaFactory implements SingletonInterface
3229
{
33-
/** @var SimpleTcaSchema[] */
3430
protected array $schemas = [];
35-
protected array $tca = [];
31+
protected array $tca;
3632

3733
public function __construct(
38-
#[Autowire(service: 'cache.core')]
39-
protected readonly PhpFrontend $cache,
40-
protected readonly FieldTypeResolver $typeResolver,
41-
) {}
34+
protected FieldTypeResolver $typeResolver,
35+
) {
36+
$this->initialize($GLOBALS['TCA'] ?? []);
37+
}
4238

4339
public function initialize(array $tca): void
4440
{
4541
$this->tca = $tca;
46-
if (($schemas = $this->getFromCache()) !== false) {
47-
$this->schemas = $schemas;
48-
return;
49-
}
5042
foreach (array_keys($this->tca) as $table) {
5143
$this->schemas[$table] = $this->build($table);
5244
}
53-
$this->setCache();
5445
}
5546

5647
public function get(string $schemaName): SimpleTcaSchema
@@ -89,15 +80,4 @@ protected function build(string $schemaName): SimpleTcaSchema
8980
$schema = new SimpleTcaSchema($schemaName, $allFields, $systemFields, $schemaDefinition['ctrl'] ?? []);
9081
return $schema;
9182
}
92-
93-
protected function getFromCache(): false|array
94-
{
95-
return $this->cache->require('ContentBlocks_SimpleTcaSchema');
96-
}
97-
98-
protected function setCache(): void
99-
{
100-
$data = 'return ' . VarExporter::export($this->schemas) . ';';
101-
$this->cache->set('ContentBlocks_SimpleTcaSchema', $data);
102-
}
10383
}

Tests/Unit/Definition/Factory/ContentBlockCompilerTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function notUniqueIdentifiersThrowAnException(array $contentBlocks): void
7777

7878
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
7979
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
80-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
80+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
8181
$contentBlockRegistry = new ContentBlockRegistry();
8282
foreach ($contentBlocks as $contentBlock) {
8383
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -143,7 +143,7 @@ public function notUniqueIdentifiersWithinCollectionThrowAnException(array $cont
143143

144144
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
145145
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
146-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
146+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
147147
$contentBlockRegistry = new ContentBlockRegistry();
148148
foreach ($contentBlocks as $contentBlock) {
149149
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -215,7 +215,7 @@ public function differentTypesPerIdentifierThrowException(array $contentBlocks):
215215

216216
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
217217
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
218-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
218+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
219219
$contentBlockRegistry = new ContentBlockRegistry();
220220
foreach ($contentBlocks as $contentBlock) {
221221
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -268,7 +268,7 @@ public function paletteInsidePaletteIsNotAllowed(): void
268268

269269
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
270270
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
271-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
271+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
272272
$contentBlockRegistry = new ContentBlockRegistry();
273273
foreach ($contentBlocks as $contentBlock) {
274274
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -327,7 +327,7 @@ public function paletteInsidePaletteInsideCollectionIsNotAllowed(): void
327327

328328
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
329329
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
330-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
330+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
331331
$contentBlockRegistry = new ContentBlockRegistry();
332332
foreach ($contentBlocks as $contentBlock) {
333333
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -397,7 +397,7 @@ public function paletteWithSameIdentifierIsNotAllowed(): void
397397

398398
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
399399
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
400-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
400+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
401401
$contentBlockRegistry = new ContentBlockRegistry();
402402
foreach ($contentBlocks as $contentBlock) {
403403
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -473,7 +473,7 @@ public function paletteWithSameIdentifierInsideCollectionIsNotAllowed(): void
473473

474474
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
475475
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
476-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
476+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
477477
$contentBlockRegistry = new ContentBlockRegistry();
478478
foreach ($contentBlocks as $contentBlock) {
479479
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -527,7 +527,7 @@ public function tabWithSameIdentifierIsNotAllowed(): void
527527

528528
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
529529
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
530-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
530+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
531531
$contentBlockRegistry = new ContentBlockRegistry();
532532
foreach ($contentBlocks as $contentBlock) {
533533
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -587,7 +587,7 @@ public function tabWithSameIdentifierInsideCollectionIsNotAllowed(): void
587587

588588
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
589589
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
590-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
590+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
591591
$contentBlockRegistry = new ContentBlockRegistry();
592592
foreach ($contentBlocks as $contentBlock) {
593593
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -639,7 +639,7 @@ public function tabInsidePaletteIsNotAllowed(): void
639639

640640
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
641641
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
642-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
642+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
643643
$contentBlockRegistry = new ContentBlockRegistry();
644644
foreach ($contentBlocks as $contentBlock) {
645645
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -697,7 +697,7 @@ public function tabInsidePaletteInsideCollectionIsNotAllowed(): void
697697

698698
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
699699
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
700-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
700+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
701701
$contentBlockRegistry = new ContentBlockRegistry();
702702
foreach ($contentBlocks as $contentBlock) {
703703
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -759,7 +759,7 @@ public function linebreaksAreOnlyAllowedWithinPalettes(): void
759759

760760
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
761761
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
762-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
762+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
763763
$contentBlockRegistry = new ContentBlockRegistry();
764764
foreach ($contentBlocks as $contentBlock) {
765765
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -818,7 +818,7 @@ public function linebreaksCanBeIgnoredIfConfiguredExplicitly(): void
818818

819819
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
820820
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
821-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
821+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
822822
$contentBlockRegistry = new ContentBlockRegistry();
823823
foreach ($contentBlocks as $contentBlock) {
824824
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -886,7 +886,7 @@ public function linebreaksAreOnlyAllowedWithinPalettesInsideCollections(): void
886886

887887
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
888888
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
889-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
889+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
890890
$contentBlockRegistry = new ContentBlockRegistry();
891891
foreach ($contentBlocks as $contentBlock) {
892892
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -935,7 +935,7 @@ public function identifierIsRequired(): void
935935

936936
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
937937
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
938-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
938+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
939939
$contentBlockRegistry = new ContentBlockRegistry();
940940
foreach ($contentBlocks as $contentBlock) {
941941
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -980,7 +980,7 @@ public function typeIsRequired(): void
980980

981981
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
982982
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
983-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
983+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
984984
$contentBlockRegistry = new ContentBlockRegistry();
985985
foreach ($contentBlocks as $contentBlock) {
986986
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1035,7 +1035,7 @@ public function identifierIsRequiredInsideCollections(): void
10351035

10361036
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
10371037
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1038-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1038+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
10391039
$contentBlockRegistry = new ContentBlockRegistry();
10401040
foreach ($contentBlocks as $contentBlock) {
10411041
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1103,7 +1103,7 @@ public function flexFieldIsNotAllowedToMixNonSheetAndSheet(): void
11031103

11041104
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
11051105
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1106-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1106+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
11071107
$contentBlockRegistry = new ContentBlockRegistry();
11081108
foreach ($contentBlocks as $contentBlock) {
11091109
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1229,7 +1229,7 @@ public function structuralFieldTypesAreNotAllowedInFlexForm(array $contentBlocks
12291229

12301230
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
12311231
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1232-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1232+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
12331233
$contentBlockRegistry = new ContentBlockRegistry();
12341234
foreach ($contentBlocks as $contentBlock) {
12351235
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1294,7 +1294,7 @@ public function sectionsHaveAtLeastOneContainerExceptionIsThrown(array $contentB
12941294

12951295
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
12961296
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1297-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1297+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
12981298
$contentBlockRegistry = new ContentBlockRegistry();
12991299
foreach ($contentBlocks as $contentBlock) {
13001300
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1365,7 +1365,7 @@ public function containerHaveAtLeastOneFieldExceptionIsThrown(array $contentBloc
13651365

13661366
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
13671367
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1368-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1368+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
13691369
$contentBlockRegistry = new ContentBlockRegistry();
13701370
foreach ($contentBlocks as $contentBlock) {
13711371
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1441,7 +1441,7 @@ public function containerContainsValidFieldTypeExceptionIsThrown(array $contentB
14411441

14421442
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
14431443
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1444-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1444+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
14451445
$contentBlockRegistry = new ContentBlockRegistry();
14461446
foreach ($contentBlocks as $contentBlock) {
14471447
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));
@@ -1497,7 +1497,7 @@ public function localCollectionsCanHaveTableOverridden(array $contentBlocks, str
14971497
{
14981498
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
14991499
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
1500-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
1500+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
15011501
$contentBlockRegistry = new ContentBlockRegistry();
15021502
foreach ($contentBlocks as $contentBlock) {
15031503
$contentBlockRegistry->register(LoadedContentBlock::fromArray($contentBlock));

Tests/Unit/Definition/Factory/DisplayCondPrefixEvaluationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function displayCondIsPrefixedForStringSyntax(): void
6161

6262
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
6363
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
64-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
64+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
6565
$contentBlockRegistry = new ContentBlockRegistry();
6666
$contentBlockRegistry->register($contentBlock);
6767
$contentBlockCompiler = new ContentBlockCompiler();
@@ -177,7 +177,7 @@ public function displayCondIsPrefixedForArraySyntax(array $displayCond, array $e
177177

178178
$fieldTypeRegistry = FieldTypeRegistryTestFactory::create();
179179
$fieldTypeResolver = new FieldTypeResolver($fieldTypeRegistry);
180-
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory(new NullFrontend('test'), $fieldTypeResolver);
180+
$simpleTcaSchemaFactory = new SimpleTcaSchemaFactory($fieldTypeResolver);
181181
$contentBlockRegistry = new ContentBlockRegistry();
182182
$contentBlockRegistry->register($contentBlock);
183183
$contentBlockCompiler = new ContentBlockCompiler();

0 commit comments

Comments
 (0)