You are here

function optimizedb_optimize_batch_finished in OptimizeDB 6

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

Completion optimization.

1 string reference to 'optimizedb_optimize_batch_finished'
optimizedb_admin_optimize_table_submit in ./optimizedb.module
Implements hook_FORM_ID_submit().

File

./optimizedb.module, line 625
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/settings/optimizedb/list_tables'),
        )), 'error');
      }
      else {
        drupal_set_message(t($message_error, array(
          '@tables' => implode(', ', $results['error']),
          '@url' => url('admin/settings/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', OPTIMIZEDB_REQUEST_TIME);
  cache_clear_all('optimizedb_tables_status', 'cache');
}