Skip to content
Snippets Groups Projects
Commit 1251cc35 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2284111 by alexpott, Berdir, damiankloip: Fixed Exceptions caught and...

Issue #2284111 by alexpott, Berdir, damiankloip: Fixed Exceptions caught and printed from index.php should not return a 200 status code.
parent 0b891207
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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) {
......
......@@ -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));
......
......@@ -22,6 +22,10 @@
$rebuild_path = $GLOBALS['base_url'] . '/rebuild.php';
$message .= " or run the <a href=\"$rebuild_path\">rebuild script</a>";
}
// Set the response code manually. Otherwise, this response will default to a
// 200.
http_response_code(500);
print $message;
throw $e;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment