You are here

public function DrupalApacheSolrService::findCaller in Apache Solr Search 7

Determine the routine that called this query.

We define "the routine that called this query" as the first entry in the call stack that is not inside /apachesolr/. That makes the climbing logic very simple, and handles variable stack depth and hook functions.

Copied from includes/database/log.inc

@link http://www.php.net/debug_backtrace

Return value

This method returns a stack trace entry similar to that generated by debug_backtrace(). However, it flattens the trace entry and the trace entry before it so that we get the function and args of the function that called into the apachesolr module, not the function and args of the Solr call itself.

1 call to DrupalApacheSolrService::findCaller()
DrupalApacheSolrService::checkResponse in ./Drupal_Apache_Solr_Service.php
Check the reponse code and thow an exception if it's not 200.

File

./Drupal_Apache_Solr_Service.php, line 478

Class

DrupalApacheSolrService
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

public function findCaller() {
  $stack = debug_backtrace();
  $stack_count = count($stack);
  for ($i = 0; $i < $stack_count; ++$i) {
    if (!isset($stack[$i]['file']) || strpos($stack[$i]['file'], DIRECTORY_SEPARATOR . 'apachesolr' . DIRECTORY_SEPARATOR) === FALSE) {
      return array(
        'file' => isset($stack[$i]['file']) ? $stack[$i]['file'] : t('Unknown'),
        'line' => isset($stack[$i]['line']) ? $stack[$i]['line'] : t('Unknown'),
        'function' => $stack[$i + 1]['function'],
        'class' => isset($stack[$i + 1]['class']) ? $stack[$i + 1]['class'] : NULL,
        'type' => isset($stack[$i + 1]['type']) ? $stack[$i + 1]['type'] : NULL,
        'args' => $stack[$i + 1]['args'],
      );
    }
  }
}