diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index cf7930d5e84997333c98d691926b5da231afbd21..a60122fb77e5b630d3c420016aa1e55400f44a95 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -39,13 +39,6 @@ */ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements SqlEntityStorageInterface { - /** - * The storage field definitions for this entity type. - * - * @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] - */ - protected $fieldStorageDefinitions; - /** * The mapping of field columns to SQL tables. * @@ -129,6 +122,17 @@ public static function createInstance(ContainerInterface $container, EntityTypeI ); } + /** + * Gets the base field definitions for a content entity type. + * + * @return \Drupal\Core\Field\FieldDefinitionInterface[] + * The array of base field definitions for the entity type, keyed by field + * name. + */ + public function getFieldStorageDefinitions() { + return $this->entityManager->getBaseFieldDefinitions($this->entityTypeId); + } + /** * Constructs a ContentEntityDatabaseStorage object. * @@ -144,7 +148,6 @@ public function __construct(EntityTypeInterface $entity_type, Connection $databa $this->database = $database; $this->entityManager = $entity_manager; - $this->fieldStorageDefinitions = $entity_manager->getBaseFieldDefinitions($entity_type->id()); // @todo Remove table names from the entity type definition in // https://drupal.org/node/2232465 @@ -236,7 +239,7 @@ protected function schemaHandler() { public function getTableMapping() { if (!isset($this->tableMapping)) { - $definitions = array_filter($this->fieldStorageDefinitions, function (FieldDefinitionInterface $definition) { + $definitions = array_filter($this->getFieldStorageDefinitions(), function (FieldDefinitionInterface $definition) { // @todo Remove the check for FieldDefinitionInterface::isMultiple() when // multiple-value base fields are supported in // https://drupal.org/node/2248977. @@ -834,10 +837,10 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam $table_mapping = $this->getTableMapping(); foreach ($table_mapping->getFieldNames($table_name) as $field_name) { - if (empty($this->fieldStorageDefinitions[$field_name])) { + if (empty($this->getFieldStorageDefinitions()[$field_name])) { throw new EntityStorageException(String::format('Table mapping contains invalid field %field.', array('%field' => $field_name))); } - $definition = $this->fieldStorageDefinitions[$field_name]; + $definition = $this->getFieldStorageDefinitions()[$field_name]; $columns = $table_mapping->getColumnNames($field_name); foreach ($columns as $column_name => $schema_name) { diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php index 0b8f6e2d2a3d5ca1cf37a73e04abd421b532fa0f..80c0b88354baf4860296d91e0120e03c3ec369a5 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php @@ -1048,7 +1048,7 @@ protected function setUpEntityStorage() { ->disableOriginalConstructor() ->getMock(); - $this->entityManager->expects($this->once()) + $this->entityManager->expects($this->any()) ->method('getBaseFieldDefinitions') ->will($this->returnValue($this->fieldDefinitions)); diff --git a/index.php b/index.php index a453ecc1f910c0b56de4a2a020f6290bbef4b25f..4d8106064e4fe65a2e9f048f899fa72005985135 100644 --- a/index.php +++ b/index.php @@ -22,6 +22,10 @@ $rebuild_path = $GLOBALS['base_url'] . '/rebuild.php'; $message .= " or run the rebuild script"; } + + // Set the response code manually. Otherwise, this response will default to a + // 200. + http_response_code(500); print $message; throw $e; }