Commit e1f84a4b authored by Pierre Rudloff's avatar Pierre Rudloff Committed by Stephen Mustgrave
Browse files

Issue #3325599: Compatibility with external_entities

parent daea3058
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\security_review\Checks;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\security_review\Check;
use Drupal\security_review\CheckResult;
@@ -36,6 +37,8 @@ class Field extends Check {

  /**
   * {@inheritdoc}
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function run() {
    $result = CheckResult::SUCCESS;
@@ -62,13 +65,17 @@ class Field extends Check {
        }
        $field_storage_definition = $field_storage_definitions[$field_name];
        if (in_array($field_storage_definition->getType(), $field_types)) {
          $entity = $entity_type_manager->getStorage($entity_type_id)
            ->getEntityType();

          // We only check entities that are stored in database.
          if (is_a($entity->getStorageClass(), SqlContentEntityStorage::class, TRUE)) {
            if ($field_storage_definition instanceof FieldStorageConfig) {
              $table = $entity_type_id . '__' . $field_name;
              $separator = '_';
              $id = 'entity_id';
            }
            else {
            $entity = $entity_type_manager->getStorage($entity_type_id)->getEntityType();
              $translatable = $entity->isTranslatable();
              $table = '';
              if ($translatable) {
@@ -80,6 +87,7 @@ class Field extends Check {
              $separator = '__';
              $id = $entity->getKey('id');
            }
          }
          $rows = \Drupal::database()->select($table, 't')
            ->fields('t')
            ->execute()