You are here

function _drupal_schema_initialize in Drupal 9

Same name and namespace in other branches
  1. 8 core/includes/schema.inc \_drupal_schema_initialize()
  2. 7 includes/common.inc \_drupal_schema_initialize()

Fills in required default values for table definitions from hook_schema().

Parameters

array $schema: The schema definition array as it was returned by the module's hook_schema().

string $module: The module for which hook_schema() was invoked.

bool $remove_descriptions: (optional) Whether to additionally remove 'description' keys of all tables and fields to improve performance of serialize() and unserialize(). Defaults to TRUE.

Deprecated

in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided.

See also

https://www.drupal.org/node/2970993

Related topics

3 calls to _drupal_schema_initialize()
drupal_install_schema in core/includes/schema.inc
Creates all tables defined in a module's hook_schema().
drupal_uninstall_schema in core/includes/schema.inc
Removes all tables defined in a module's hook_schema().
SchemaDeprecationTest::testDeprecatedSchemaInitialize in core/tests/Drupal/KernelTests/Core/Extension/SchemaDeprecationTest.php
Tests deprecation of _drupal_schema_initialize() function.

File

core/includes/schema.inc, line 202
Schema API handling functions.

Code

function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
  @trigger_error('_drupal_schema_initialize() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED);

  // 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']);
      }
    }
  }
}