-
Notifications
You must be signed in to change notification settings - Fork 17
IBX-9379: Added Grace Period for archived versions #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
72aa20f
3acd147
48b0db3
337df43
9a166df
2f88274
d51676d
d41399c
f1f89fb
01f457b
7d895a2
b14af0f
13bcc0e
9966027
6efedc8
12feb97
8e5548b
6875253
7ebad66
d979a0a
0c35b84
9efaa4b
56fa8f1
7df510b
42b39cf
bec0cb4
32d3da4
811e55c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Bundle\Core\EventSubscriber; | ||
|
|
||
| use Ibexa\Core\Persistence\Cache\Identifier\CacheIdentifierGeneratorInterface; | ||
| use Ibexa\Core\Repository\Collector\ContentCollector; | ||
| use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; | ||
| use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
| use Symfony\Component\HttpKernel\Event\TerminateEvent; | ||
| use Symfony\Component\HttpKernel\KernelEvents; | ||
|
|
||
| final class ClearCollectedContentCacheSubscriber implements EventSubscriberInterface | ||
| { | ||
| private TagAwareAdapterInterface $cache; | ||
|
|
||
| private CacheIdentifierGeneratorInterface $identifierGenerator; | ||
|
|
||
| private ContentCollector $contentCollector; | ||
|
|
||
| public function __construct( | ||
| ContentCollector $contentCollector, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICS, this service is not shared, so won't that make it always new instance when injecting? Meaning are the items that you've collected in ContentService be available here in this instance?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this works in a little bit different, with making sure that it is not shared between requests in for example long living proceses, but I think you might be right (or we both are - and potential gains outweights problems) so I will remove shared config from service.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That would be my expectation, but then maybe - given its generic name and namespace location - it should be a named service with some interface? Someone could be tempted to reuse this for different purpose. Meaning defining it like: ibexa.core.content.collector.grace_period:
class: ...\ContentCollectorInterfaceso sb can create his own instance: app.content.collector.my_other_purpose:
class: ...\ContentCollectorInterface |
||
| TagAwareAdapterInterface $cache, | ||
| CacheIdentifierGeneratorInterface $identifierGenerator | ||
| ) { | ||
| $this->cache = $cache; | ||
| $this->identifierGenerator = $identifierGenerator; | ||
| $this->contentCollector = $contentCollector; | ||
| } | ||
|
|
||
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [KernelEvents::TERMINATE => 'clearCache']; | ||
| } | ||
|
|
||
| public function clearCache(TerminateEvent $event): void | ||
| { | ||
| foreach ($this->contentCollector->getCollectedContentIds() as $contentId) { | ||
| $this->cache->invalidateTags([ | ||
| $this->identifierGenerator->generateTag('content', [$contentId]), | ||
| ]); | ||
| } | ||
|
|
||
| $this->contentCollector->reset(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,6 +304,12 @@ services: | |
| tags: | ||
| - {name: kernel.event_subscriber} | ||
|
|
||
| Ibexa\Bundle\Core\EventSubscriber\ClearCollectedContentCacheSubscriber: | ||
| autowire: true | ||
| autoconfigure: true | ||
| arguments: | ||
| $cache: '@ibexa.cache_pool' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can just change type to |
||
|
|
||
| Ibexa\Bundle\Core\EventSubscriber\TrustedHeaderClientIpEventSubscriber: | ||
| arguments: | ||
| $trustedHeaderName: '%ibexa.trusted_header_client_ip_name%' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Core\Repository\Collector; | ||
|
|
||
| use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||
| use Symfony\Contracts\Service\ResetInterface; | ||
|
|
||
| final class ContentCollector implements ResetInterface | ||
| { | ||
| /** @var array<int, bool> */ | ||
| private array $contentMap = []; | ||
|
|
||
| public function collectContent(Content $content): void | ||
| { | ||
| $this->contentMap[$content->getId()] = false; | ||
| } | ||
|
|
||
| /** | ||
| * @return int[] | ||
| */ | ||
| public function getCollectedContentIds(): array | ||
| { | ||
| return array_keys($this->contentMap); | ||
| } | ||
|
|
||
| public function reset(): void | ||
| { | ||
| $this->contentMap = []; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.