• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FluidTYPO3 / flux / 21825983806

09 Feb 2026 12:57PM UTC coverage: 92.657% (-0.01%) from 92.669%
21825983806

Pull #2278

github

web-flow
Merge a353ae440 into 128c243a0
Pull Request #2278: [BUGFIX] Fallback to empty TS in request-less contexts

1 of 2 new or added lines in 1 file covered. (50.0%)

7092 of 7654 relevant lines covered (92.66%)

66.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.15
/Classes/Service/TypoScriptService.php
1
<?php
2
namespace FluidTYPO3\Flux\Service;
3

4
/*
5
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use FluidTYPO3\Flux\Utility\ExtensionNamingUtility;
12
use TYPO3\CMS\Core\SingletonInterface;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
15
use TYPO3\CMS\Extbase\Configuration\Exception\NoServerRequestGivenException;
16

17
class TypoScriptService implements SingletonInterface
18
{
19
    private CacheService $cacheService;
20
    private ConfigurationManagerInterface $configurationManager;
21

22
    public function __construct(CacheService $cacheService, ConfigurationManagerInterface $configurationManager)
23
    {
24
        $this->cacheService = $cacheService;
28✔
25
        $this->configurationManager = $configurationManager;
28✔
26
    }
27

28
    /**
29
     * Returns the plugin.tx_extsignature.settings array.
30
     * Accepts any input extension name type.
31
     */
32
    public function getSettingsForExtensionName(string $extensionName): array
33
    {
34
        $signature = ExtensionNamingUtility::getExtensionSignature($extensionName);
7✔
35
        return (array) $this->getTypoScriptByPath('plugin.tx_' . $signature . '.settings');
7✔
36
    }
37

38
    /**
39
     * Gets the value/array from global TypoScript by
40
     * dotted path expression.
41
     *
42
     * @return array|mixed
43
     */
44
    public function getTypoScriptByPath(string $path)
45
    {
46
        $cacheId = md5('ts_' . $path);
28✔
47
        $fromCache = $this->cacheService->getFromCaches($cacheId);
28✔
48
        if ($fromCache) {
28✔
49
            return $fromCache;
7✔
50
        }
51

52
        try {
53
            $all = $this->configurationManager->getConfiguration(
21✔
54
                ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
21✔
55
            );
21✔
56
        } catch (NoServerRequestGivenException $error) {
14✔
57
            // This case may happen when trying to read TypoScript from a CLI context. In this case, rather than just
58
            // giving up, we return an empty set of TypoScript.
NEW
59
            $all = [];
×
60
        } catch (\RuntimeException $exception) {
14✔
61
            if ($exception->getCode() !== 1700841298) {
14✔
62
                throw $exception;
7✔
63
            }
64
            // This will happen only on v13 and only when Flux is being triggered in uncached contexts (basically,
65
            // INT cObject types). The reason is that TS is not available in such contexts through ServerRequest.
66
            // This imposes a set of limitations on Flux in such contexts:
67
            // - Any and all TypoScript settings will not be available.
68
            // - This includes view path configurations - only default paths and/or paths specified by the Provider
69
            //   will be available when Flux tries to render things.
70
            // This affects several features of Flux, such as the ability to override Form details through TypoScript.
71
            // The affected features *ARE* relatively rarely used, but there's no reasonable way around it. The only
72
            // way that this *could* have been patched would be to reproduce all of the code from
73
            // TYPO3\CMS\Frontend\Middleware\PrepareTypoScriptFrontendRendering, which involves from-scratch attempting
74
            // to read, compile and finally parse every single TypoScript template throughout the root line.
75
            // A decision has been made that this is so excessive it will not be attempted. So, sorry, but if your use
76
            // case demands that you MUST have TypoScript available in your Flux context in uncached contexts on v13+,
77
            // your only option will be to replace this class and override this method, filling it with your preferred
78
            // way of reading TypoScript when it cannot be read from the ServerRequest "frontend.typoscript" attribute.
79
            $all = [];
7✔
80
        }
81

82
        $value = &$all;
14✔
83
        foreach (explode('.', $path) as $segment) {
14✔
84
            $value = ($value[$segment . '.'] ?? $value[$segment] ?? null);
14✔
85
            if ($value === null) {
14✔
86
                break;
7✔
87
            }
88
        }
89
        if (is_array($value)) {
14✔
90
            $value = GeneralUtility::removeDotsFromTS($value);
7✔
91
        }
92
        $this->cacheService->setInCaches($value, true, $cacheId);
14✔
93
        return $value;
14✔
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc