Skip to content
Snippets Groups Projects
Commit e0927c51 authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

Issue #3427554 by claudiu.cristea: Postpone URI deletion in destruction phase

parent 16591856
No related branches found
No related tags found
1 merge request!8Update 2 files
Pipeline #118108 passed with warnings
...@@ -152,9 +152,5 @@ function rdf_sync_entity_delete(EntityInterface $entity): void { ...@@ -152,9 +152,5 @@ function rdf_sync_entity_delete(EntityInterface $entity): void {
$mapper = \Drupal::getContainer()->get('rdf_sync.mapper'); $mapper = \Drupal::getContainer()->get('rdf_sync.mapper');
if ($entity instanceof ContentEntityInterface && $mapper->isMappedEntity($entity)) { if ($entity instanceof ContentEntityInterface && $mapper->isMappedEntity($entity)) {
\Drupal::getContainer()->get('rdf_sync.synchronizer')->synchronize(SyncMethod::DELETE, [$entity]); \Drupal::getContainer()->get('rdf_sync.synchronizer')->synchronize(SyncMethod::DELETE, [$entity]);
\Drupal::database()->delete('rdf_sync_uri')
->condition('entity_type', $entity->getEntityTypeId())
->condition('entity_id', $entity->id())
->execute();
} }
} }
...@@ -45,6 +45,7 @@ services: ...@@ -45,6 +45,7 @@ services:
- '@queue' - '@queue'
- '@rdf_sync.mapper' - '@rdf_sync.mapper'
- '@rdf_sync.normalizer' - '@rdf_sync.normalizer'
- '@database'
tags: tags:
- { name: needs_destruction } - { name: needs_destruction }
rdf_sync.normalizer.subscriber: rdf_sync.normalizer.subscriber:
......
...@@ -4,6 +4,7 @@ declare(strict_types=1); ...@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\rdf_sync; namespace Drupal\rdf_sync;
use Drupal\Core\Database\Connection;
use Drupal\Core\DestructableInterface; use Drupal\Core\DestructableInterface;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Queue\QueueFactory; use Drupal\Core\Queue\QueueFactory;
...@@ -35,6 +36,8 @@ class RdfSyncSynchronizer implements DestructableInterface { ...@@ -35,6 +36,8 @@ class RdfSyncSynchronizer implements DestructableInterface {
* The RDF Sync mapper service. * The RDF Sync mapper service.
* @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer * @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer
* The RDF Sync normalizer. * The RDF Sync normalizer.
* @param \Drupal\Core\Database\Connection $database
* The database connection.
*/ */
public function __construct( public function __construct(
protected StateInterface $state, protected StateInterface $state,
...@@ -42,6 +45,7 @@ class RdfSyncSynchronizer implements DestructableInterface { ...@@ -42,6 +45,7 @@ class RdfSyncSynchronizer implements DestructableInterface {
protected QueueFactory $queueFactory, protected QueueFactory $queueFactory,
protected RdfSyncMapper $mapper, protected RdfSyncMapper $mapper,
protected NormalizerInterface $normalizer, protected NormalizerInterface $normalizer,
protected Connection $database,
) {} ) {}
/** /**
...@@ -121,6 +125,11 @@ class RdfSyncSynchronizer implements DestructableInterface { ...@@ -121,6 +125,11 @@ class RdfSyncSynchronizer implements DestructableInterface {
$entities, $entities,
); );
RdfSyncConnection::deleteTriples($uris); RdfSyncConnection::deleteTriples($uris);
// Update {rdf_sync_uri} table.
if ($method === SyncMethod::DELETE) {
$this->database->delete('rdf_sync_uri')->condition('uri', $uris, 'IN')->execute();
}
} }
if (in_array($method, [SyncMethod::INSERT, SyncMethod::UPDATE], TRUE)) { if (in_array($method, [SyncMethod::INSERT, SyncMethod::UPDATE], TRUE)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment