Commit 5ccb4329 authored by catch's avatar catch

Issue #1969136 by swentel: Move field_reserved_columns() to a static method.

parent f67a09b2
......@@ -1184,15 +1184,6 @@ function _field_create_entity_from_ids($ids) {
return entity_create($ids->entity_type, $id_properties);
}
/**
* A list of columns that can not be used as field type columns.
*
* @return array
*/
function field_reserved_columns() {
return array('deleted');
}
/**
* Implements hook_hook_info().
*/
......
......@@ -446,7 +446,7 @@ public function getSchema() {
$schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array());
// Check that the schema does not include forbidden column names.
if (array_intersect(array_keys($schema['columns']), field_reserved_columns())) {
if (array_intersect(array_keys($schema['columns']), static::getReservedColumns())) {
throw new FieldException('Illegal field type columns.');
}
......@@ -563,5 +563,13 @@ public function unserialize($serialized) {
$this->__construct(unserialize($serialized));
}
/**
* A list of columns that can not be used as field type columns.
*
* @return array
*/
public static function getReservedColumns() {
return array('deleted');
}
}
......@@ -8,6 +8,7 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Entity\EntityInterface;
use Drupal\field\FieldUpdateForbiddenException;
use Drupal\field\Plugin\Core\Entity\Field;
/**
* Implements hook_help().
......@@ -93,7 +94,7 @@ function _field_sql_storage_revision_tablename($field) {
* unique among all other fields.
*/
function _field_sql_storage_columnname($name, $column) {
return in_array($column, field_reserved_columns()) ? $column : $name . '_' . $column;
return in_array($column, Field::getReservedColumns()) ? $column : $name . '_' . $column;
}
/**
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\field\Plugin\Core\Entity\Field;
/**
* Adds tables and fields to the SQL entity query.
......@@ -118,7 +119,7 @@ function addField($field, $type, $langcode) {
if ($key < $count) {
$next = $specifiers[$key + 1];
// Is this a field column?
if (isset($field['columns'][$next]) || in_array($next, field_reserved_columns())) {
if (isset($field['columns'][$next]) || in_array($next, Field::getReservedColumns())) {
// Use it.
$column = $next;
// Do not process it again.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment