Browse Source

No infinite derivatives.

pull/920/head
Rosie Le Faive 2 years ago
parent
commit
0b7f12d3ba
  1. 4
      src/EventGenerator/EmitEvent.php
  2. 7
      src/Plugin/Action/AbstractGenerateDerivative.php

4
src/EventGenerator/EmitEvent.php

@ -157,6 +157,10 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
$user = $this->entityTypeManager->getStorage('user')->load($this->account->id());
$data = $this->generateData($entity);
// If $data is the bool false, then abort. No error, but don't emit event.
if ($data === FALSE) {
return;
}
$event = $this->eventDispatcher->dispatch(
StompHeaderEvent::EVENT_NAME,

7
src/Plugin/Action/AbstractGenerateDerivative.php

@ -60,6 +60,13 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
throw new \RuntimeException("Could not locate taxonomy term with uri: " . $this->configuration['derivative_term_uri'], 500);
}
// See if there is a destination media already set, and abort if it's the
// same as the source media. Dont cause an error, just don't continue.
$derivative_media = $this->utils->getMediaWithTerm($entity, $derivative_term);
if (!is_null($derivative_media) && $derivative_media->id() == $source_media->id()) {
return FALSE;
}
$route_params = [
'node' => $entity->id(),
'media_type' => $this->configuration['destination_media_type'],

Loading…
Cancel
Save