Skip to content

Commit 969f5ad

Browse files
Merge tag 'v1.7.39' into develop
v1.7.39
2 parents be6c7f2 + 154a044 commit 969f5ad

File tree

6 files changed

+63
-15
lines changed

6 files changed

+63
-15
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [v1.7.39](https://github.com/roadiz/roadiz/compare/v1.7.38...v1.7.39) (2024-07-10)
2+
3+
4+
### Bug Fixes
5+
6+
* Fixed Roadiz with no solr configured or no async messenger handling ([acf92d4](https://github.com/roadiz/roadiz/commit/acf92d46c51b60b1b01d38a0dc69a3c4fb7e74bb))
7+
18
## [v1.7.38](https://github.com/roadiz/roadiz/compare/v1.7.37...v1.7.38) (2024-06-06)
29

310

src/Roadiz/Core/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Kernel implements ServiceProviderInterface, KernelInterface, RebootableInt
7070
const SECURITY_DOMAIN = 'roadiz_domain';
7171
const INSTALL_CLASSNAME = InstallApp::class;
7272
public static ?string $cmsBuild = null;
73-
public static string $cmsVersion = "1.7.38";
73+
public static string $cmsVersion = "1.7.39";
7474
protected string $environment;
7575
protected bool $debug;
7676
/**

src/Roadiz/Core/SearchEngine/Indexer/IndexerFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
namespace RZ\Roadiz\Core\SearchEngine\Indexer;
55

66
use LogicException;
7+
use Psr\Container\ContainerExceptionInterface;
78
use Psr\Container\ContainerInterface;
9+
use Psr\Container\NotFoundExceptionInterface;
810
use RZ\Roadiz\Core\Entities\Document;
911
use RZ\Roadiz\Core\Entities\Folder;
1012
use RZ\Roadiz\Core\Entities\Node;
@@ -26,6 +28,8 @@ public function __construct(ContainerInterface $serviceLocator)
2628
/**
2729
* @param class-string $classname
2830
* @return Indexer
31+
* @throws ContainerExceptionInterface
32+
* @throws NotFoundExceptionInterface
2933
*/
3034
public function getIndexerFor(string $classname): Indexer
3135
{

src/Roadiz/Core/SearchEngine/Message/Handler/SolrDeleteMessageHandler.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

44
namespace RZ\Roadiz\Core\SearchEngine\Message\Handler;
55

6+
use Psr\Container\ContainerExceptionInterface;
7+
use Psr\Container\NotFoundExceptionInterface;
68
use Psr\Log\LoggerInterface;
79
use Psr\Log\NullLogger;
8-
use RZ\Roadiz\Core\SearchEngine\Indexer\IndexerFactory;
910
use RZ\Roadiz\Core\Exceptions\SolrServerNotAvailableException;
10-
use RZ\Roadiz\Core\SearchEngine\Message\SolrReindexMessage;
11+
use RZ\Roadiz\Core\Exceptions\SolrServerNotConfiguredException;
12+
use RZ\Roadiz\Core\SearchEngine\Indexer\IndexerFactory;
13+
use RZ\Roadiz\Core\SearchEngine\Message\AbstractSolrMessage;
1114
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
1215

1316
final class SolrDeleteMessageHandler implements MessageHandlerInterface
@@ -25,14 +28,21 @@ public function __construct(IndexerFactory $indexerFactory, ?LoggerInterface $lo
2528
$this->indexerFactory = $indexerFactory;
2629
}
2730

28-
public function __invoke(SolrReindexMessage $message)
31+
public function __invoke(AbstractSolrMessage $message)
2932
{
33+
if (null === $message->getIdentifier()) {
34+
return;
35+
}
3036
try {
3137
$this->indexerFactory->getIndexerFor($message->getClassname())->delete($message->getIdentifier());
38+
} catch (SolrServerNotConfiguredException $exception) {
39+
// do nothing
3240
} catch (SolrServerNotAvailableException $exception) {
3341
$this->logger->info($exception);
3442
} catch (\LogicException $exception) {
3543
$this->logger->error($exception);
44+
} catch (ContainerExceptionInterface $e) {
45+
$this->logger->error($e);
3646
}
3747
}
3848
}

src/Roadiz/Core/SearchEngine/Message/Handler/SolrReindexMessageHandler.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
namespace RZ\Roadiz\Core\SearchEngine\Message\Handler;
55

6+
use Psr\Container\ContainerExceptionInterface;
67
use Psr\Log\LoggerInterface;
78
use Psr\Log\NullLogger;
89
use RZ\Roadiz\Core\Exceptions\SolrServerNotAvailableException;
10+
use RZ\Roadiz\Core\Exceptions\SolrServerNotConfiguredException;
911
use RZ\Roadiz\Core\SearchEngine\Indexer\IndexerFactory;
10-
use RZ\Roadiz\Core\SearchEngine\Message\SolrReindexMessage;
12+
use RZ\Roadiz\Core\SearchEngine\Message\AbstractSolrMessage;
1113
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
1214

1315
final class SolrReindexMessageHandler implements MessageHandlerInterface
@@ -25,14 +27,21 @@ public function __construct(IndexerFactory $indexerFactory, ?LoggerInterface $lo
2527
$this->indexerFactory = $indexerFactory;
2628
}
2729

28-
public function __invoke(SolrReindexMessage $message)
30+
public function __invoke(AbstractSolrMessage $message)
2931
{
32+
if (null === $message->getIdentifier()) {
33+
return;
34+
}
3035
try {
3136
$this->indexerFactory->getIndexerFor($message->getClassname())->index($message->getIdentifier());
37+
} catch (SolrServerNotConfiguredException $exception) {
38+
// do nothing
3239
} catch (SolrServerNotAvailableException $exception) {
3340
$this->logger->info($exception);
3441
} catch (\LogicException $exception) {
3542
$this->logger->error($exception);
43+
} catch (ContainerExceptionInterface $e) {
44+
$this->logger->error($e);
3645
}
3746
}
3847
}

src/Roadiz/Core/SearchEngine/Subscriber/SolariumSubscriber.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function getSubscribedEvents()
7979
public function onSolariumNodeWorkflowComplete(Event $event): void
8080
{
8181
$node = $event->getSubject();
82-
if ($node instanceof Node) {
82+
if ($node instanceof Node && null !== $node->getId()) {
8383
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Node::class, $node->getId())));
8484
}
8585
}
@@ -93,7 +93,10 @@ public function onSolariumNodeWorkflowComplete(Event $event): void
9393
*/
9494
public function onSolariumSingleUpdate(NodesSourcesUpdatedEvent $event)
9595
{
96-
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(NodesSources::class, $event->getNodeSource()->getId())));
96+
$id = $event->getNodeSource()->getId();
97+
if (null !== $id) {
98+
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(NodesSources::class, $id)));
99+
}
97100
}
98101

99102
/**
@@ -103,7 +106,10 @@ public function onSolariumSingleUpdate(NodesSourcesUpdatedEvent $event)
103106
*/
104107
public function onSolariumSingleDelete(NodesSourcesDeletedEvent $event)
105108
{
106-
$this->messageBus->dispatch(new Envelope(new SolrDeleteMessage(NodesSources::class, $event->getNodeSource()->getId())));
109+
$id = $event->getNodeSource()->getId();
110+
if (null !== $id) {
111+
$this->messageBus->dispatch(new Envelope(new SolrDeleteMessage(NodesSources::class, $id)));
112+
}
107113
}
108114

109115
/**
@@ -113,7 +119,10 @@ public function onSolariumSingleDelete(NodesSourcesDeletedEvent $event)
113119
*/
114120
public function onSolariumNodeDelete(NodeDeletedEvent $event)
115121
{
116-
$this->messageBus->dispatch(new Envelope(new SolrDeleteMessage(Node::class, $event->getNode()->getId())));
122+
$id = $event->getNode()->getId();
123+
if (null !== $id) {
124+
$this->messageBus->dispatch(new Envelope(new SolrDeleteMessage(Node::class, $id)));
125+
}
117126
}
118127

119128
/**
@@ -125,7 +134,10 @@ public function onSolariumNodeDelete(NodeDeletedEvent $event)
125134
*/
126135
public function onSolariumNodeUpdate(FilterNodeEvent $event)
127136
{
128-
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Node::class, $event->getNode()->getId())));
137+
$id = $event->getNode()->getId();
138+
if (null !== $id) {
139+
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Node::class, $id)));
140+
}
129141
}
130142

131143

@@ -137,7 +149,7 @@ public function onSolariumNodeUpdate(FilterNodeEvent $event)
137149
public function onSolariumDocumentDelete(FilterDocumentEvent $event)
138150
{
139151
$document = $event->getDocument();
140-
if ($document instanceof Document) {
152+
if ($document instanceof Document && null !== $document->getId()) {
141153
$this->messageBus->dispatch(new Envelope(new SolrDeleteMessage(Document::class, $document->getId())));
142154
}
143155
}
@@ -152,7 +164,7 @@ public function onSolariumDocumentDelete(FilterDocumentEvent $event)
152164
public function onSolariumDocumentUpdate(FilterDocumentEvent $event)
153165
{
154166
$document = $event->getDocument();
155-
if ($document instanceof Document) {
167+
if ($document instanceof Document && null !== $document->getId()) {
156168
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Document::class, $document->getId())));
157169
}
158170
}
@@ -167,7 +179,10 @@ public function onSolariumDocumentUpdate(FilterDocumentEvent $event)
167179
*/
168180
public function onSolariumTagUpdate(TagUpdatedEvent $event)
169181
{
170-
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Tag::class, $event->getTag()->getId())));
182+
$id = $event->getTag()->getId();
183+
if (null !== $id) {
184+
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Tag::class, $id)));
185+
}
171186
}
172187

173188
/**
@@ -180,6 +195,9 @@ public function onSolariumTagUpdate(TagUpdatedEvent $event)
180195
*/
181196
public function onSolariumFolderUpdate(FolderUpdatedEvent $event)
182197
{
183-
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Folder::class, $event->getFolder()->getId())));
198+
$id = $event->getFolder()->getId();
199+
if (null !== $id) {
200+
$this->messageBus->dispatch(new Envelope(new SolrReindexMessage(Folder::class, $id)));
201+
}
184202
}
185203
}

0 commit comments

Comments
 (0)