You are here

function optimizedb_optimize_batch_finished in OptimizeDB 7

Same name and namespace in other branches
  1. 6 optimizedb.module \optimizedb_optimize_batch_finished()

Output results when a batch is complete.

Callback for batch_set().

Parameters

bool $success: A boolean indicating whether the batch operation successfully concluded.

int $results: The results from the batch process.

array $operations: The batch operations that remained unprocessed. Only relevant if $success is FALSE.

1 string reference to 'optimizedb_optimize_batch_finished'
optimizedb_admin_optimize_table_submit in ./optimizedb.module
Form submission handler for optimizedb_admin().

File

./optimizedb.module, line 745
Database Optimization.

Code

function optimizedb_optimize_batch_finished($success, $results, $operations) {
  if ($success) {
    if (isset($results['error'])) {
      $message_error = 'When optimizing experiencing errors with tables:
        @tables. You need as quickly as possible <a href="@url">to check the table</a>. Other tables
        were successfully optimized.';
      if (PHP_SAPI == 'cli') {
        drush_log(dt($message_error, array(
          '@tables' => implode(', ', $results['error']),
          '@url' => url('admin/config/development/optimizedb/list_tables'),
        )), 'error');
      }
      else {
        drupal_set_message(t($message_error, array(
          '@tables' => implode(', ', $results['error']),
          '@url' => url('admin/config/development/optimizedb/list_tables'),
        )), 'error');
      }
    }
    else {
      $message_success = 'Optimized @count tables.';
      if (PHP_SAPI == 'cli') {
        drush_log(dt($message_success, array(
          '@count' => count($results['success']),
        )), 'success');
      }
      else {
        drupal_set_message(t($message_success, array(
          '@count' => count($results['success']),
        )));
      }
    }
  }
  else {
    $message_error = 'Completed with errors.';
    if (PHP_SAPI == 'cli') {
      drush_log(dt($message_error), 'error');
    }
    else {
      drupal_set_message(t($message_error), 'error');
    }
  }
  variable_set('optimizedb_notify_optimize', FALSE);
  variable_set('optimizedb_last_optimization', REQUEST_TIME);
}