Commit 567ec7de authored by Dries's avatar Dries

- Issue #1817684 by damiankloip, dawehner, tim.plunkett: Use state() instead...

- Issue #1817684 by damiankloip, dawehner, tim.plunkett: Use state() instead of variable_set() and remove redundant saveBlockCache() method in Block.php display plugin.
parent be488fb2
......@@ -197,7 +197,6 @@ public function submitOptionsForm(&$form, &$form_state) {
break;
case 'block_caching':
$this->setOption('block_caching', $form_state['values']['block_caching']);
$this->saveBlockCache($form_state['view']->storage->get('name') . '-'. $form_state['display_id'], $form_state['values']['block_caching']);
break;
}
}
......@@ -216,7 +215,7 @@ public function usesExposed() {
* Update the block delta when you change the machine readable name of the display.
*/
protected function updateBlockBid($name, $old_delta, $delta) {
$old_hashes = $hashes = variable_get('views_block_hashes', array());
$old_hashes = $hashes = state()->get('views_block_hashes');
$old_delta = $name . '-' . $old_delta;
$delta = $name . '-' . $delta;
......@@ -240,27 +239,7 @@ protected function updateBlockBid($name, $old_delta, $delta) {
// Update the hashes if needed.
if ($hashes != $old_hashes) {
variable_set('views_block_hashes', $hashes);
}
}
/**
* Save the block cache setting in the blocks table if this block allready
* exists in the blocks table. Dirty fix untill http://drupal.org/node/235673 gets in.
*/
protected function saveBlockCache($delta, $cache_setting) {
if (strlen($delta) >= 32) {
$delta = md5($delta);
}
if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(
':delta' => $delta))->fetchField()) {
db_update('block')
->fields(array(
'cache' => $cache_setting,
))
->condition('module', 'views')
->condition('delta', $delta)
->execute();
state()->set('views_block_hashes', $hashes);
}
}
......
......@@ -669,9 +669,9 @@ function views_block_info() {
}
// Only save hashes if they have changed.
$old_hashes = variable_get('views_block_hashes', array());
$old_hashes = state()->get('views_block_hashes');
if ($hashes != $old_hashes) {
variable_set('views_block_hashes', $hashes);
state()->set('views_block_hashes', $hashes);
}
views_cache_set('views_block_items', $items, TRUE);
......@@ -686,7 +686,7 @@ function views_block_view($delta) {
$start = microtime(TRUE);
// if this is 32, this should be an md5 hash.
if (strlen($delta) == 32) {
$hashes = variable_get('views_block_hashes', array());
$hashes = state()->get('views_block_hashes');
if (!empty($hashes[$delta])) {
$delta = $hashes[$delta];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment