Skip to content

Commit d23907b

Browse files
committed
[BUGFIX] Fix TypeError in EXT:lowlevel from reverseProxyProvider
proxycachemanager stored the proxy provider object in TYPO3_CONF_VARS. Through its dependencies, the "TYPO3_CONF_VARS" view of the Configuration module ended up rendering the whole service container, which lead to an TypeError, since ConfigurationController::renderTree() expects type ArrayObject|array and an Map Object was given. The patch removes the object from the configuration.
1 parent 8a5d816 commit d23907b

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎Classes/Cache/Backend/ReverseProxyCacheBackend.php‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
use B13\Proxycachemanager\Provider\ProxyProviderInterface;
21+
use B13\Proxycachemanager\ProxyConfiguration;
2122
use Psr\Log\LoggerAwareTrait;
2223
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
2324
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
@@ -32,7 +33,7 @@
3233
class ReverseProxyCacheBackend extends Typo3DatabaseBackend
3334
{
3435
use LoggerAwareTrait;
35-
protected ProxyProviderInterface $reverseProxyProvider;
36+
protected ?ProxyProviderInterface $reverseProxyProvider = null;
3637
protected ?FrontendInterface $frontend = null;
3738

3839
/**
@@ -50,16 +51,25 @@ public function setReverseProxyProvider(ProxyProviderInterface $reverseProxyProv
5051
$this->reverseProxyProvider = $reverseProxyProvider;
5152
}
5253

54+
/**
55+
* The provider is resolved lazily instead of being passed as cache option, so no
56+
* object instance needs to be stored in $GLOBALS['TYPO3_CONF_VARS'].
57+
* */
58+
protected function getReverseProxyProvider(): ProxyProviderInterface
59+
{
60+
return $this->reverseProxyProvider ??= GeneralUtility::makeInstance(ProxyConfiguration::class)->getProxyProvider();
61+
}
62+
5363
/**
5464
* Removes all cache entries of this cache.
5565
* Also let the proxy provider know to clear everything as well.
5666
*/
5767
public function flush(): void
5868
{
5969
// make the HTTP Purge call
60-
if ($this->reverseProxyProvider->isActive()) {
70+
if ($this->getReverseProxyProvider()->isActive()) {
6171
$urls = $this->getAllCachedUrls();
62-
$this->reverseProxyProvider->flushAllUrls($urls);
72+
$this->getReverseProxyProvider()->flushAllUrls($urls);
6373
}
6474
parent::flush();
6575
}
@@ -71,12 +81,12 @@ public function flush(): void
7181
*/
7282
public function flushByTag($tag): void
7383
{
74-
if ($this->reverseProxyProvider->isActive()) {
84+
if ($this->getReverseProxyProvider()->isActive()) {
7585
$identifiers = $this->findIdentifiersByTag($tag);
7686
foreach ($identifiers as $entryIdentifier) {
7787
$url = $this->resolveCachedUrl($entryIdentifier);
7888
if ($url !== null) {
79-
$this->reverseProxyProvider->flushCacheForUrls([$url]);
89+
$this->getReverseProxyProvider()->flushCacheForUrls([$url]);
8090
}
8191
}
8292
}
@@ -91,7 +101,7 @@ public function flushByTag($tag): void
91101
*/
92102
public function flushByTags(array $tags): void
93103
{
94-
if ($this->reverseProxyProvider->isActive()) {
104+
if ($this->getReverseProxyProvider()->isActive()) {
95105
$identifiers = [];
96106
foreach ($tags as $tag) {
97107
$identifiers = array_merge($identifiers, $this->findIdentifiersByTag($tag));
@@ -108,7 +118,7 @@ public function flushByTags(array $tags): void
108118
$urls = array_unique($urls);
109119

110120
if ($urls !== []) {
111-
$this->reverseProxyProvider->flushCacheForUrls($urls);
121+
$this->getReverseProxyProvider()->flushCacheForUrls($urls);
112122
}
113123
}
114124

‎ext_localconf.php‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
defined('TYPO3') or die();
44

5-
use B13\Proxycachemanager\ProxyConfiguration;
6-
use TYPO3\CMS\Core\Utility\GeneralUtility;
7-
85
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_proxy'] ?? null)) {
96
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_proxy'] = [
107
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
118
'backend' => \B13\Proxycachemanager\Cache\Backend\ReverseProxyCacheBackend::class,
129
'options' => [
1310
'defaultLifetime' => 0, // @todo: should be not "infinite" but rather set to whatever the proxy settings are
14-
'reverseProxyProvider' => (GeneralUtility::makeInstance(ProxyConfiguration::class))->getProxyProvider(),
1511
],
1612
// setting the pages group makes sure that when the page cache is cleared, that this cache is cleared as well
1713
'groups' => ['pages', 'proxy'],

0 commit comments

Comments
 (0)