By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta10
Issue links:
Description:
For Entity tables in Drupal 8 we don't use hook_schema() anymore. Given that, drupal_get_schema(), drupal_get_complete_schema(), drupal_get_schema_unprocessed() and hook_schema_alter() do not work anymore. There is no replacement for hook_schema_alter().
Get the schema of a table defined in .install
Before
$schema = drupal_get_schema($table);
$schema = drupal_get_schema_unprocessed($table);
After
$schema = drupal_get_module_schema($module, $table);
Get the schema of an entity table
Before
$schema = drupal_get_schema($table);
After
... there is no API for that
Impacts:
Module developers
Comments
external database conneciton via views db connector module issue
Hi,
I am trying to connect my Drupal8 website to an external database I created and use this database through views database connector module; https://www.drupal.org/project/views_database_connector
Unfortunately this module includes some of these deprecated functions, there is a patch that partially replaces these functions but leaves "drupal_get_complete_schema()" in still. https://www.drupal.org/node/2610480; #15
The error I get looks like this; PHP Fatal error: Call to undefined function drupal_get_complete_schema() in drupal/modules/views_database_connector/views_database_connector.views.inc on line 197
and block inside views_database_connector.views.inc looks like this;
function views_database_connector_get_database_schema_mysql($key) {
// Load the appropriate data type groups.
$types = views_database_connector_get_data_types();
// Switch to database in question.
db_set_active($key);
// Get a list of the tables in this database.
$tables = db_query('SHOW TABLES;');
// Switch back to the main database.
db_set_active('default');
$tablelist = array();
// Fetch a row, each with a table name.
while ($row = $tables->fetchAssoc()) {
// This is the one of two database formats that can have whacky table
// names due to using information_schema. We have the ability to
// check on columns without the PDO table substitution problem.
foreach ($row as $v) {
if (!in_array($v, array_keys(drupal_get_complete_schema()))) {
// Switch to database in question.
db_set_active($key);
// Fetch column names and their data type from said table.
$q = 'SELECT column_name, data_type FROM ';
$q .= 'information_schema.columns WHERE table_name = :table;';
$cols = db_query($q, array(':table' => $v));
// Switch back to the main database.
db_set_active('default');
$collist = array();
// Fetch a row, each with a column name.
while ($r = $cols->fetchAssoc()) {
$t = 'broken';
// Add column to column list.
if (isset($r['column_name'])) {
foreach ($types as $type => $matches) {
foreach ($matches as $match) {
if (stristr($r['data_type'], $match)) {
$t = $type;
}
So, any advice as to how I can go around this problem or what I should replace drupal get complete schema() function with woud be appreciated, thank you in advance :)