You are here

protected function Block::updateBlockBid in Views (for Drupal 7) 8.3

Update the block delta when you change the machine readable name of the display.

1 call to Block::updateBlockBid()
Block::submitOptionsForm in lib/Views/block/Plugin/views/display/Block.php
Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.

File

lib/Views/block/Plugin/views/display/Block.php, line 221
Definition of Drupal\views\Plugin\views\display\Block. Definition of Views\block\Plugin\views\display\Block.

Class

Block
The plugin that handles a block.

Namespace

Views\block\Plugin\views\display

Code

protected function updateBlockBid($name, $old_delta, $delta) {
  $old_hashes = $hashes = variable_get('views_block_hashes', array());
  $old_delta = $name . '-' . $old_delta;
  $delta = $name . '-' . $delta;
  if (strlen($old_delta) >= 32) {
    $old_delta = md5($old_delta);
    unset($hashes[$old_delta]);
  }
  if (strlen($delta) >= 32) {
    $md5_delta = md5($delta);
    $hashes[$md5_delta] = $delta;
    $delta = $md5_delta;
  }

  // Maybe people don't have block module installed, so let's skip this.
  if (db_table_exists('block')) {
    db_update('block')
      ->fields(array(
      'delta' => $delta,
    ))
      ->condition('delta', $old_delta)
      ->execute();
  }

  // Update the hashes if needed.
  if ($hashes != $old_hashes) {
    variable_set('views_block_hashes', $hashes);
  }
}