function drupal_get_schema_unprocessed

Returns the unprocessed and unaltered version of a module's schema.

Use this function only if you explicitly need the original specification of a schema, as it was defined in a module's hook_schema(). No additional default values will be set, hook_schema_alter() is not invoked and these unprocessed definitions won't be cached.

This function can be used to retrieve a schema specification in hook_schema(), so it allows you to derive your tables from existing specifications.

It is also used by drupal_install_schema() and drupal_uninstall_schema() to ensure that a module's tables are created exactly as specified without any changes introduced by a module that implements hook_schema_alter().

Parameters

string $module: The module to which the table belongs.

string $table: The name of the table. If not given, the module's complete schema is returned.

Related topics

6 calls to drupal_get_schema_unprocessed()
DrupalUnitTestBase::installSchema in drupal/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
Installs a specific table from a module schema definition.
drupal_install_schema in drupal/core/includes/schema.inc
Creates all tables defined in a module's hook_schema().
drupal_uninstall_schema in drupal/core/includes/schema.inc
Removes all tables defined in a module's hook_schema().
ModuleTestBase::assertModuleTablesDoNotExist in drupal/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php
Assert that none of the tables defined in a module's hook_schema() exist.
ModuleTestBase::assertModuleTablesExist in drupal/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php
Assert that all tables defined in a module's hook_schema() exist.

... See full list

File

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

Code

function drupal_get_schema_unprocessed($module, $table = NULL) {

  // Load the .install file to get hook_schema.
  module_load_install($module);
  $schema = module_invoke($module, 'schema');
  if (isset($table)) {
    if (isset($schema[$table])) {
      return $schema[$table];
    }
    return array();
  }
  elseif (!empty($schema)) {
    return $schema;
  }
  return array();
}