background_process.install in Background Process 6
Same filename and directory in other branches
This is the installation file for the Background Process module
File
background_process.installView source
<?php
/**
 * @file
 * This is the installation file for the Background Process module
 */
/**
 * Implements hook_enable().
 */
function background_process_enable() {
  $_SESSION['background_process_determine_default_service_host'] = TRUE;
}
/**
 * Implements hook_install().
 */
function background_process_install() {
  drupal_install_schema('background_process');
}
/**
 * Implements hook_uninstall().
 */
function background_process_uninstall() {
  drupal_uninstall_schema('background_process');
  // Removing process variables.
  variable_del('background_process_service_timeout');
  variable_del('background_process_connection_timeout');
  variable_del('background_process_stream_timeout');
  variable_del('background_process_service_groups');
  variable_del('background_process_default_service_group');
  variable_del('background_process_service_hosts');
  variable_del('background_process_default_service_host');
  variable_del('background_process_cleanup_age');
  variable_del('background_process_queues');
  variable_del('background_process_derived_default_host');
  variable_del('background_process_token');
}
/**
 * Implements hook_schema().
 */
function background_process_schema() {
  $schema = array();
  $schema['background_process'] = array(
    'fields' => array(
      'handle' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'callback' => array(
        'type' => 'text',
        'not null' => FALSE,
      ),
      'args' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'token' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'service_host' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'start_stamp' => array(
        'type' => 'varchar',
        'length' => '18',
        'not null' => FALSE,
      ),
      'exec_status' => array(
        'type' => 'int',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'handle',
    ),
  );
  return $schema;
}
/**
 * Implements hook_requirements().
 */
function background_process_requirements($phase) {
  $response = array();
  switch ($phase) {
    case 'install':
      return $response;
    case 'runtime':
      $response['title'] = 'Background Process';
      $response['value'] = t('OK');
      $response['severity'] = REQUIREMENT_OK;
      if (ini_get('safe_mode')) {
        $desc = t('Safe mode enabled. Background Process is unable to control maximum execution time for background processes. This may cause background processes to end prematurely.');
        if ($response['severity'] < REQUIREMENT_WARNING) {
          $response['severity'] = REQUIREMENT_WARNING;
          $response['value'] = t('Safe mode enabled');
          $response['description'] = $desc;
        }
        else {
          $response['description'] .= '<br/>' . $desc;
        }
      }
      $result = array();
      $result['background_process'] = $response;
      return $result;
  }
}
/**
 * Add status field to table
 */
function background_process_update_6001() {
  $ret = array();
  db_add_field($ret, 'background_process', 'status', array(
    'type' => 'int',
    'size' => 'normal',
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}
/**
 * Determine default service host
 */
function background_process_update_6101() {
  $ret = array();
  return $ret;
}
/**
 * Determine default service host
 */
function background_process_update_6102() {
  $ret = array();
  return $ret;
}
/**
 * Determine default service host
 */
function background_process_update_6103() {
  drupal_set_message(st('Update complete. Please visit !settings page and determine default service host, if not configured in settings.php', array(
    '!settings' => l('settings', 'admin/settings/background-process/settings'),
  )));
  $ret = array();
  return $ret;
}
/**
 * Change start column from double to numeric
 */
function background_process_update_6104() {
  $ret = array();
  db_change_field($ret, 'background_process', 'start', 'start', array(
    'type' => 'numeric',
    'precision' => '16',
    'scale' => '6',
    'not null' => FALSE,
  ));
  return $ret;
}
/**
 * Re-determine default service host.
 */
function background_process_update_6105() {
  $_SESSION['background_process_determine_default_service_host'] = TRUE;
  $ret = array();
  return $ret;
}
/**
 * Change schema to SQL 99 compliance
 */
function background_process_update_6106() {
  $ret = array();
  db_change_field($ret, 'background_process', 'start', 'start_stamp', array(
    'type' => 'varchar',
    'length' => '18',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'background_process', 'status', 'exec_status', array(
    'type' => 'int',
    'size' => 'normal',
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}
/**
 * Increase size of args column
 */
function background_process_update_6107() {
  db_change_field($ret, 'background_process', 'args', 'args', array(
    'type' => 'blob',
    'size' => 'big',
    'not null' => FALSE,
  ));
  return $ret;
}Functions
| Name   | Description | 
|---|---|
| background_process_enable | Implements hook_enable(). | 
| background_process_install | Implements hook_install(). | 
| background_process_requirements | Implements hook_requirements(). | 
| background_process_schema | Implements hook_schema(). | 
| background_process_uninstall | Implements hook_uninstall(). | 
| background_process_update_6001 | Add status field to table | 
| background_process_update_6101 | Determine default service host | 
| background_process_update_6102 | Determine default service host | 
| background_process_update_6103 | Determine default service host | 
| background_process_update_6104 | Change start column from double to numeric | 
| background_process_update_6105 | Re-determine default service host. | 
| background_process_update_6106 | Change schema to SQL 99 compliance | 
| background_process_update_6107 | Increase size of args column | 
