You are here

function boost_update_6117 in Boost 6

Update 6117 - Update page_id column so it uses varchar - Fix for views

File

./boost.install, line 1219
Handles Boost module installation and upgrade tasks.

Code

function boost_update_6117() {
  $GLOBALS['_boost_max_execution_time'] = ini_get('max_execution_time');
  ini_set('max_execution_time', 10800);

  //3 Hours
  _boost_install_set_time_limit(0);
  $ret = array();

  // Edit filename column & set PK
  $result = db_query("SELECT * FROM {boost_cache_settings} WHERE page_callback = 'view' AND page_id <> 0");
  while ($old = db_fetch_array($result)) {
    drupal_set_message(t('Due to a bug in Boost, this view\'s scope was not set correctly. It has been deleted, and needs to be re-set.<br /><br /> Base Dir: %dir<br /> View Name: %args<br /> Cache Lifetime: %time', array(
      '%dir' => $old['base_dir'],
      '%args' => $old['page_arguments'],
      '%time' => format_interval($old['lifetime'], 1),
    )), 'warning');
    $ret[] = update_sql('DELETE FROM {boost_cache_settings} WHERE csid = %d', $old['csid']);
    $ret[] = array(
      'success' => TRUE,
      'query' => t('This setting needs to be re-set.<br /><br /> Base Dir: %dir<br /> View Name: %args<br /> Cache Lifetime: %time', array(
        '%dir' => $old['base_dir'],
        '%args' => $old['page_arguments'],
        '%time' => format_interval($old['lifetime'], 1),
      )),
    );
  }
  db_drop_index($ret, 'boost_cache', 'page_id');
  db_change_field($ret, 'boost_cache', 'page_id', 'page_id', array(
    'description' => 'The ID of the page.',
    'type' => 'varchar',
    'length' => 64,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_index($ret, 'boost_cache', 'page_id', array(
    'page_id',
  ));
  db_drop_index($ret, 'boost_cache_settings', 'page_id');
  db_change_field($ret, 'boost_cache_settings', 'page_id', 'page_id', array(
    'description' => 'The ID of the page.',
    'type' => 'varchar',
    'length' => 64,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_index($ret, 'boost_cache_settings', 'page_id', array(
    'page_id',
  ));
  _boost_install_set_time_limit(0);
  ini_set('max_execution_time', $GLOBALS['_boost_max_execution_time']);
  return $ret;
}