function _drupal_schema_initialize
Same name in other branches
- 9 core/includes/schema.inc \_drupal_schema_initialize()
- 8.9.x core/includes/schema.inc \_drupal_schema_initialize()
Fills in required default values for table definitions from hook_schema().
Parameters
$schema: The schema definition array as it was returned by the module's hook_schema().
$module: The module for which hook_schema() was invoked.
$remove_descriptions: (optional) Whether to additionally remove 'description' keys of all tables and fields to improve performance of serialize() and unserialize(). Defaults to TRUE.
Related topics
3 calls to _drupal_schema_initialize()
- drupal_get_complete_schema in includes/
bootstrap.inc - Gets the whole database schema.
- drupal_install_schema in includes/
common.inc - Creates all tables defined in a module's hook_schema().
- drupal_uninstall_schema in includes/
common.inc - Removes all tables defined in a module's hook_schema().
File
-
includes/
common.inc, line 7384
Code
function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
// Set the name and module key for all tables.
foreach ($schema as $name => &$table) {
if (empty($table['module'])) {
$table['module'] = $module;
}
if (!isset($table['name'])) {
$table['name'] = $name;
}
if ($remove_descriptions) {
unset($table['description']);
foreach ($table['fields'] as &$field) {
unset($field['description']);
}
}
// Set the type key for all fields where it is not set (mostly when using
// datatabase specific data types).
foreach ($table['fields'] as &$field) {
if (!isset($field['type'])) {
$field['type'] = NULL;
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.