- Issue #1817684 by damiankloip, dawehner, tim.plunkett: Use state() instead of variable_set() and remove redundant saveBlockCache() method in Block.php display plugin.
parent
be488fb299
commit
567ec7deef
|
@ -197,7 +197,6 @@ class Block extends DisplayPluginBase {
|
||||||
break;
|
break;
|
||||||
case 'block_caching':
|
case 'block_caching':
|
||||||
$this->setOption('block_caching', $form_state['values']['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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +215,7 @@ class Block extends DisplayPluginBase {
|
||||||
* Update the block delta when you change the machine readable name of the display.
|
* Update the block delta when you change the machine readable name of the display.
|
||||||
*/
|
*/
|
||||||
protected function updateBlockBid($name, $old_delta, $delta) {
|
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;
|
$old_delta = $name . '-' . $old_delta;
|
||||||
$delta = $name . '-' . $delta;
|
$delta = $name . '-' . $delta;
|
||||||
|
@ -240,27 +239,7 @@ class Block extends DisplayPluginBase {
|
||||||
|
|
||||||
// Update the hashes if needed.
|
// Update the hashes if needed.
|
||||||
if ($hashes != $old_hashes) {
|
if ($hashes != $old_hashes) {
|
||||||
variable_set('views_block_hashes', $hashes);
|
state()->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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -669,9 +669,9 @@ function views_block_info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only save hashes if they have changed.
|
// 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) {
|
if ($hashes != $old_hashes) {
|
||||||
variable_set('views_block_hashes', $hashes);
|
state()->set('views_block_hashes', $hashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
views_cache_set('views_block_items', $items, TRUE);
|
views_cache_set('views_block_items', $items, TRUE);
|
||||||
|
@ -686,7 +686,7 @@ function views_block_view($delta) {
|
||||||
$start = microtime(TRUE);
|
$start = microtime(TRUE);
|
||||||
// if this is 32, this should be an md5 hash.
|
// if this is 32, this should be an md5 hash.
|
||||||
if (strlen($delta) == 32) {
|
if (strlen($delta) == 32) {
|
||||||
$hashes = variable_get('views_block_hashes', array());
|
$hashes = state()->get('views_block_hashes');
|
||||||
if (!empty($hashes[$delta])) {
|
if (!empty($hashes[$delta])) {
|
||||||
$delta = $hashes[$delta];
|
$delta = $hashes[$delta];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue