Loading src/Checks/Field.php +22 −14 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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) { Loading @@ -80,6 +87,7 @@ class Field extends Check { $separator = '__'; $id = $entity->getKey('id'); } } $rows = \Drupal::database()->select($table, 't') ->fields('t') ->execute() Loading Loading
src/Checks/Field.php +22 −14 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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) { Loading @@ -80,6 +87,7 @@ class Field extends Check { $separator = '__'; $id = $entity->getKey('id'); } } $rows = \Drupal::database()->select($table, 't') ->fields('t') ->execute() Loading