summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/bootstrap.inc7
-rw-r--r--includes/common.inc26
2 files changed, 22 insertions, 11 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index c4d52e27c..53897c683 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2593,7 +2593,6 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// On some databases this function may be called before bootstrap has
// been completed, so we force the functions we need to load just in case.
if (function_exists('module_load_all_includes')) {
-
// There is currently a bug in module_list() where it caches what it
// was last called with, which is not always what you want.
// module_load_all_includes() calls module_list(), but if this function
@@ -2601,7 +2600,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// uninitialized and therefore return no modules. Instead, we have to
// "prime" module_list() here to to values we want, specifically
// "yes rebuild the list and don't limit to bootstrap".
- // TODO: Remove this call after http://drupal.org/node/222109 is fixed.
+ // @todo Remove this call after http://drupal.org/node/222109 is fixed.
module_list(TRUE, FALSE);
module_load_all_includes('install');
}
@@ -2613,7 +2612,9 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// would cause array_merge() to set the $schema variable to NULL as well.
// That would break modules which use $schema further down the line.
$current = (array) module_invoke($module, 'schema');
- _drupal_schema_initialize($module, $current);
+ // Set 'module' and 'name' keys for each table, and remove descriptions,
+ // as they needlessly slow down cache_get() for every single request.
+ _drupal_schema_initialize($current, $module);
$schema = array_merge($schema, $current);
}
diff --git a/includes/common.inc b/includes/common.inc
index 568115a86..6611d418c 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -6030,7 +6030,7 @@ function drupal_common_theme() {
*/
function drupal_install_schema($module) {
$schema = drupal_get_schema_unprocessed($module);
- _drupal_schema_initialize($module, $schema);
+ _drupal_schema_initialize($schema, $module, FALSE);
foreach ($schema as $name => $table) {
db_create_table($name, $table);
@@ -6053,7 +6053,7 @@ function drupal_install_schema($module) {
*/
function drupal_uninstall_schema($module) {
$schema = drupal_get_schema_unprocessed($module);
- _drupal_schema_initialize($module, $schema);
+ _drupal_schema_initialize($schema, $module, FALSE);
foreach ($schema as $table) {
if (db_table_exists($table['name'])) {
@@ -6103,20 +6103,30 @@ function drupal_get_schema_unprocessed($module, $table = NULL) {
/**
* Fill in required default values for table definitions returned by hook_schema().
*
- * @param $module
- * The module for which hook_schema() was invoked.
* @param $schema
* The schema definition array as it was returned by the module's
* hook_schema().
+ * @param $module
+ * The module for which hook_schema() was invoked.
+ * @param $remove_descriptions
+ * (optional) Whether to additionally remove 'description' keys of all tables
+ * and fields to improve performance of serialize() and unserialize().
+ * Defaults to TRUE.
*/
-function _drupal_schema_initialize($module, &$schema) {
+function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
// Set the name and module key for all tables.
- foreach ($schema as $name => $table) {
+ foreach ($schema as $name => &$table) {
if (empty($table['module'])) {
- $schema[$name]['module'] = $module;
+ $table['module'] = $module;
}
if (!isset($table['name'])) {
- $schema[$name]['name'] = $name;
+ $table['name'] = $name;
+ }
+ if ($remove_descriptions) {
+ unset($table['description']);
+ foreach ($table['fields'] as &$field) {
+ unset($field['description']);
+ }
}
}
}