Skip to content

Commit b1798f0

Browse files
author
roadiz-ci
committed
Merge branch hotfix/v2.4.5
1 parent caefc8a commit b1798f0

File tree

5 files changed

+40
-37
lines changed

5 files changed

+40
-37
lines changed

config/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
parameters:
3-
roadiz_core.cms_version: '2.4.4'
3+
roadiz_core.cms_version: '2.4.5'
44
roadiz_core.cms_version_prefix: 'main'
55
env(APP_NAMESPACE): "roadiz"
66
env(APP_VERSION): "0.1.0"

src/Cache/CloudflareProxyCache.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public function __construct(
1010
private string $name,
1111
private string $zone,
1212
private string $version,
13-
private string $bearer,
14-
private string $email,
15-
private string $key,
13+
private ?string $bearer,
14+
private ?string $email,
15+
private ?string $key,
1616
private int $timeout,
1717
) {
1818
}
@@ -32,17 +32,17 @@ public function getVersion(): string
3232
return $this->version;
3333
}
3434

35-
public function getBearer(): string
35+
public function getBearer(): ?string
3636
{
3737
return $this->bearer;
3838
}
3939

40-
public function getEmail(): string
40+
public function getEmail(): ?string
4141
{
4242
return $this->email;
4343
}
4444

45-
public function getKey(): string
45+
public function getKey(): ?string
4646
{
4747
return $this->key;
4848
}

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ protected function addSolrNode()
144144
$builder = new TreeBuilder('solr');
145145
$node = $builder->getRootNode();
146146

147-
$node->addDefaultsIfNotSet()
148-
->children()
147+
$node->children()
149148
->scalarNode('timeout')->defaultValue(3)->end()
150149
->arrayNode('endpoints')
150+
->defaultValue([])
151151
->useAttributeAsKey('name')
152152
->prototype('array')
153153
->children()
154-
->scalarNode('host')->defaultValue('127.0.0.1')->end()
154+
->scalarNode('host')->isRequired()->end()
155155
->scalarNode('username')->end()
156156
->scalarNode('password')->end()
157157
->scalarNode('core')->isRequired()->end()
@@ -178,7 +178,6 @@ protected function addReverseProxyCacheNode()
178178
$node = $builder->getRootNode();
179179
$node->children()
180180
->arrayNode('frontend')
181-
->isRequired()
182181
->useAttributeAsKey('name')
183182
->prototype('array')
184183
->children()
@@ -195,7 +194,6 @@ protected function addReverseProxyCacheNode()
195194
->end()
196195
->end()
197196
->arrayNode('cloudflare')
198-
->addDefaultsIfNotSet()
199197
->children()
200198
->scalarNode('version')
201199
->defaultValue('v4')

src/DependencyInjection/RoadizCoreExtension.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ private function registerReverseProxyCache(array $config, ContainerBuilder $cont
145145
$reverseProxyCacheFrontendsReferences[] = new Reference($definitionName);
146146
}
147147

148-
if (
149-
isset($config['reverseProxyCache']['cloudflare'])
150-
&& isset($config['reverseProxyCache']['cloudflare']['bearer'])
151-
) {
148+
if (isset($config['reverseProxyCache']['cloudflare'])) {
152149
$container->setDefinition(
153150
'roadiz_core.reverse_proxy_cache.cloudflare',
154151
(new Definition())
@@ -158,9 +155,9 @@ private function registerReverseProxyCache(array $config, ContainerBuilder $cont
158155
'cloudflare',
159156
$config['reverseProxyCache']['cloudflare']['zone'],
160157
$config['reverseProxyCache']['cloudflare']['version'],
161-
$config['reverseProxyCache']['cloudflare']['bearer'],
162-
$config['reverseProxyCache']['cloudflare']['email'],
163-
$config['reverseProxyCache']['cloudflare']['key'],
158+
$config['reverseProxyCache']['cloudflare']['bearer'] ?? null,
159+
$config['reverseProxyCache']['cloudflare']['email'] ?? null,
160+
$config['reverseProxyCache']['cloudflare']['key'] ?? null,
164161
$config['reverseProxyCache']['cloudflare']['timeout'],
165162
])
166163
);
@@ -202,6 +199,9 @@ private function registerEntityGenerator(array $config, ContainerBuilder $contai
202199

203200
private function registerSolr(array $config, ContainerBuilder $container): void
204201
{
202+
if (!isset($config['solr'])) {
203+
return;
204+
}
205205
$solrEndpoints = [];
206206
$container->setDefinition(
207207
'roadiz_core.solr.adapter',
@@ -211,20 +211,18 @@ private function registerSolr(array $config, ContainerBuilder $container): void
211211
->addMethodCall('setTimeout', [$config['solr']['timeout']])
212212
->addMethodCall('setConnectionTimeout', [$config['solr']['timeout']])
213213
);
214-
if (isset($config['solr'])) {
215-
foreach ($config['solr']['endpoints'] as $name => $endpoint) {
216-
$container->setDefinition(
217-
'roadiz_core.solr.endpoints.'.$name,
218-
(new Definition())
219-
->setClass(Endpoint::class)
220-
->setPublic(true)
221-
->setArguments([
222-
$endpoint,
223-
])
224-
->addMethodCall('setKey', [$name])
225-
);
226-
$solrEndpoints[] = 'roadiz_core.solr.endpoints.'.$name;
227-
}
214+
foreach ($config['solr']['endpoints'] as $name => $endpoint) {
215+
$container->setDefinition(
216+
'roadiz_core.solr.endpoints.'.$name,
217+
(new Definition())
218+
->setClass(Endpoint::class)
219+
->setPublic(true)
220+
->setArguments([
221+
$endpoint,
222+
])
223+
->addMethodCall('setKey', [$name])
224+
);
225+
$solrEndpoints[] = 'roadiz_core.solr.endpoints.'.$name;
228226
}
229227
if (count($solrEndpoints) > 0) {
230228
$logger = new Reference(SolariumLogger::class);

src/EventSubscriber/CloudflareCacheEventSubscriber.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public static function getSubscribedEvents(): array
4040

4141
protected function supportConfig(): bool
4242
{
43-
return null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache();
43+
return null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache() &&
44+
(
45+
null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getBearer() ||
46+
null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache()->getEmail()
47+
);
4448
}
4549

4650
public function onBanRequest(CachePurgeRequestEvent $event): void
@@ -118,9 +122,12 @@ protected function createRequest(array $body): HttpRequestMessageInterface
118122
$headers = [
119123
'Content-type' => 'application/json',
120124
];
121-
$headers['Authorization'] = 'Bearer '.trim($this->getCloudflareCacheProxy()->getBearer());
122-
$headers['X-Auth-Email'] = $this->getCloudflareCacheProxy()->getEmail();
123-
$headers['X-Auth-Key'] = $this->getCloudflareCacheProxy()->getKey();
125+
if (null !== $this->getCloudflareCacheProxy()->getBearer()) {
126+
$headers['Authorization'] = 'Bearer '.trim($this->getCloudflareCacheProxy()->getBearer());
127+
} else {
128+
$headers['X-Auth-Email'] = $this->getCloudflareCacheProxy()->getEmail();
129+
$headers['X-Auth-Key'] = $this->getCloudflareCacheProxy()->getKey();
130+
}
124131

125132
$uri = sprintf(
126133
'https://api.cloudflare.com/client/%s/zones/%s/purge_cache',

0 commit comments

Comments
 (0)