You are here

function jsonlog_update_7002 in JSONlog 7.2

Converts conf variable jsonlog_file to jsonlog_dir.

File

./jsonlog.install, line 33
Install, update and uninstall functions for the JSONlog module.

Code

function jsonlog_update_7002() {
  if (!db_select('variable')
    ->fields('variable', array(
    'value',
  ))
    ->condition('name', 'jsonlog_dir', '=')
    ->execute()
    ->fetchField() && ($file = db_select('variable')
    ->fields('variable', array(
    'value',
  ))
    ->condition('name', 'jsonlog_file', '=')
    ->execute()
    ->fetchField())) {
    $dir = dirname(unserialize($file));
    db_insert('variable')
      ->fields(array(
      'name',
      'value',
    ), array(
      'jsonlog_dir',
      serialize($dir),
    ))
      ->execute();
    db_delete('variable')
      ->condition('name', array(
      'jsonlog_file',
    ), 'IN')
      ->execute();
  }
}