function apachesolr_index_batch_index_finished in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.admin.inc \apachesolr_index_batch_index_finished()
- 7 apachesolr.admin.inc \apachesolr_index_batch_index_finished()
Batch 'finished' callback
Parameters
bool $success: Whether the batch ended with success or not
array $results:
array $operations:
1 string reference to 'apachesolr_index_batch_index_finished'
- apachesolr_index_batch_index_remaining in ./
apachesolr.admin.inc - Submit a batch job to index the remaining, non-indexed content.
File
- ./
apachesolr.admin.inc, line 1220 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_index_batch_index_finished($success, array $results, array $operations) {
$message = '';
// $results['count'] will not be set if Solr is unavailable.
if (isset($results['count'])) {
$message .= format_plural($results['count'], '1 item processed successfully. ', '@count items successfully processed. ');
}
if (isset($results['submitted'])) {
$message .= format_plural($results['submitted'], '1 document successfully sent to Solr.', '@count documents successfully sent to Solr.');
}
if ($success) {
// Directly process those documents if direct commit was enabled.
$direct_commit = apachesolr_environment_variable_get($results['env_id'], 'apachesolr_direct_commit', FALSE);
if ($direct_commit) {
// Get the $solr object
$solr = apachesolr_get_solr($results['env_id']);
$solr
->commit();
}
$type = 'status';
}
else {
// An error occurred. $operations contains the unprocessed operations.
$error_operation = reset($operations);
$message .= ' ' . t('An error occurred while processing @num with arguments: @args', array(
'@num' => $error_operation[0],
'@args' => print_r($error_operation[0], TRUE),
));
$type = 'error';
}
drupal_set_message($message, $type);
}