summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-06-18 07:07:06 (GMT)
committerwebchick2014-06-18 07:07:06 (GMT)
commit1251cc35a7f78e803ec99f836120496f445b8b84 (patch)
tree593f36bc29c54704f03f4fd8ad0333285315e816
parent0b8912073d4a8ba82b007ab92fe8733b64a59862 (diff)
Issue #2284111 by alexpott, Berdir, damiankloip: Fixed Exceptions caught and printed from index.php should not return a 200 status code.
-rw-r--r--core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php25
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php2
-rw-r--r--index.php4
3 files changed, 19 insertions, 12 deletions
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index cf7930d..a60122f 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
@@ -40,13 +40,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
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.
*
* @var \Drupal\Core\Entity\Sql\TableMappingInterface
@@ -130,6 +123,17 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
}
/**
+ * 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.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
@@ -144,7 +148,6 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
$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 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
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 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
$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 0b8f6e2..80c0b88 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php
@@ -1048,7 +1048,7 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
->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 a453ecc..4d81060 100644
--- a/index.php
+++ b/index.php
@@ -22,6 +22,10 @@ catch (Exception $e) {
$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;
}