summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-08-19 08:08:45 +0000
committerDries Buytaert <dries@buytaert.net>2007-08-19 08:08:45 +0000
commit74292cd0625032180b2d178ae1c57e51462f121e (patch)
tree79ffaafcf1cd4c7b4a2dd2d33512228a0efb597c /modules/system
parente9c36f969752488ca33da745b15805c489932a30 (diff)
downloadbrdo-74292cd0625032180b2d178ae1c57e51462f121e.tar.gz
brdo-74292cd0625032180b2d178ae1c57e51462f121e.tar.bz2
- Patch #80951 by killes, yched et al: block caching.
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.install46
-rw-r--r--modules/system/system.module23
2 files changed, 65 insertions, 4 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 56205fdc9..ffa68b16a 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -3481,6 +3481,52 @@ function system_update_6026() {
}
/**
+ * Add block cache.
+ */
+function system_update_6027() {
+ $ret = array();
+
+ // Create the blocks.cache column.
+ db_add_field($ret, 'blocks', 'cache', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
+
+ // Create the cache_block table.
+ $schema['cache_block'] = array(
+ 'fields' => array(
+ 'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+ 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'headers' => array('type' => 'text', 'not null' => FALSE),
+ 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
+ ),
+ 'indexes' => array('expire' => array('expire')),
+ 'primary key' => array('cid'),
+ );
+ db_create_table($ret, 'cache_block', $schema['cache_block']);
+
+ // Fill in the values for the new 'cache' column,
+ // by refreshing the {blocks} table.
+ global $theme, $custom_theme;
+ $old_theme = $theme;
+ $themes = list_themes();
+
+ $result = db_query("SELECT DISTINCT theme FROM {blocks}");
+ while ($row = db_fetch_array($result)) {
+ if (array_key_exists($row['theme'], $themes)) {
+ // Set up global values so that _blocks_rehash()
+ // operates on the expected theme.
+ $theme = NULL;
+ $custom_theme = $row['theme'];
+ _block_rehash();
+ }
+ }
+
+ $theme = $old_theme;
+
+ return $ret;
+}
+
+/**
* @} End of "defgroup updates-5.x-to-6.x"
* The next series of updates should start at 7000.
*/
diff --git a/modules/system/system.module b/modules/system/system.module
index 9fc049644..e0152b5f1 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -683,7 +683,7 @@ function system_performance_settings() {
$form['page_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Page cache'),
- '#description' => t('Enabling the cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time someone wants to view it.'),
+ '#description' => t('Enabling the page cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time someone wants to view it.'),
);
$form['page_cache']['cache'] = array(
@@ -701,7 +701,22 @@ function system_performance_settings() {
'#title' => t('Minimum cache lifetime'),
'#default_value' => variable_get('cache_lifetime', 0),
'#options' => $period,
- '#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
+ '#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time. This setting also affects block caching.')
+ );
+
+ $form['block_cache'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Block cache'),
+ '#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on every page load. If page cache is also enabled, this performance increase will mainly affect authenticated users.'),
+ );
+
+ $form['block_cache']['block_cache'] = array(
+ '#type' => 'radios',
+ '#title' => t('Block cache'),
+ '#default_value' => variable_get('block_cache', CACHE_DISABLED),
+ '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Enabled (recommended)')),
+ '#disabled' => count(module_implements('node_grants')),
+ '#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
);
$form['bandwidth_optimizations'] = array(
@@ -1275,8 +1290,8 @@ function system_initialize_theme_blocks($theme) {
if (!array_key_exists($block['region'], $regions)) {
$block['region'] = system_default_region($theme);
}
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)",
- $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
+ db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, %d)",
+ $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['cache']);
}
}
}