Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jibran on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.4.x
Introduced in version:
8.4.0-rc2
Issue links:
Description:
A new helper method addNextBaseTable
is added to \Drupal\Core\Entity\Query\Sql\Tables
. This factors out the relationship entity table join into a method so contrib modules can add different column for JOINs than the column used in field storage.
For example in dynamic_entity_reference the sql_column
is changed like this.
/**
* {@inheritdoc}
*/
protected function addNextBaseTable(EntityType $entity_type, $table, $sql_column) {
// Parent method is overridden in order to choose the correct column to
// join on (string or int).
$entity_type_id_key = $entity_type->getKey('id');
if ($entity_type_id_key !== FALSE) {
if (DynamicEntityReferenceItem::entityHasIntegerId($entity_type->id())) {
$sql_column .= '_int';
}
}
return parent::addNextBaseTable($entity_type, $table, $sql_column);
}
To make the Tables::addNextBaseField()
more usable in #2908605: Pass field storage to Tables::addNextBaseField() a new parameter $field_storage
is add to the function in 8.4.x before 8.4.0-rc2.
After (8.4.0-rc2):
/**
* {@inheritdoc}
*/
protected function addNextBaseTable(EntityType $entity_type, $table, $sql_column) {
$field_storage = func_get_arg(3);
// Parent method is overridden in order to choose the correct column to
// join on (string or int).
$entity_type_id_key = $entity_type->getKey('id');
if (($field_storage->getType() === 'dynamic_entity_reference') && ($entity_type_id_key !== FALSE)) {
if (DynamicEntityReferenceItem::entityHasIntegerId($entity_type->id())) {
$sql_column .= '_int';
}
}
return parent::addNextBaseTable($entity_type, $table, $sql_column);
}
After (8.5.0-aplha1):
/**
* {@inheritdoc}
*/
protected function addNextBaseTable(EntityType $entity_type, $table, $sql_column, FieldStorageDefinitionInterface $field_storage) {
// Parent method is overridden in order to choose the correct column to
// join on (string or int).
$entity_type_id_key = $entity_type->getKey('id');
if (($field_storage->getType() === 'dynamic_entity_reference') && ($entity_type_id_key !== FALSE)) {
if (DynamicEntityReferenceItem::entityHasIntegerId($entity_type->id())) {
$sql_column .= '_int';
}
}
return parent::addNextBaseTable($entity_type, $table, $sql_column);
}
Impacts:
Module developers