diff --git a/src/Commands/core/EntityCommands.php b/src/Commands/core/EntityCommands.php index 70a7d7b8b9..4b8b7e52d8 100644 --- a/src/Commands/core/EntityCommands.php +++ b/src/Commands/core/EntityCommands.php @@ -15,7 +15,6 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Entity\RevisionLogInterface; use Drupal\Core\Session\AccountInterface; use Drush\Attributes as CLI; @@ -181,8 +180,9 @@ public function doSave(string $entity_type, array $ids, ?string $action, ?string $message = []; $storage = $this->entityTypeManager->getStorage($entity_type); $entities = $storage->loadMultiple($ids); + $is_revisionable = $this->entityTypeManager->getDefinition($entity_type)->isRevisionable(); foreach ($entities as $entity) { - if (is_a($entity, RevisionableInterface::class)) { + if ($is_revisionable) { /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ $storage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId()); $entity = $storage->createRevision($entity, true); @@ -211,7 +211,9 @@ public function doSave(string $entity_type, array $ids, ?string $action, ?string $message = 'Unpublished.'; } } - if (is_a($entity, RevisionLogInterface::class)) { + if ($is_revisionable) { + // This line satisfies the bully that is phpstan. + assert($entity instanceof RevisionLogInterface); $entity->setRevisionLogMessage('Re-saved by Drush entity:save. ' . $message); $entity->setRevisionCreationTime($this->time->getRequestTime()); $entity->setRevisionUserId($this->currentUser->id());