I have some simple code tested, right now I just add this to the bottom of httprl.module and things work.

// timer_start() is one of the first functions drupal calls in its bootstrap.
if (!function_exists('timer_start')) {
  function timer_start($name) {
    global $timers;

    list($usec, $sec) = explode(' ', microtime());
    $timers[$name]['start'] = (float) $usec + (float) $sec;
    $timers[$name]['count'] = isset($timers[$name]['count']) ? ++$timers[$name]['count'] : 1;
  }

  function timer_stop($name) {
    global $timers;

    $timers[$name]['time'] = timer_read($name);
    unset($timers[$name]['start']);

    return $timers[$name];
  }

  function timer_read($name) {
    global $timers;

    if (isset($timers[$name]['start'])) {
      list($usec, $sec) = explode(' ', microtime());
      $stop = (float) $usec + (float) $sec;
      $diff = round(($stop - $timers[$name]['start']) * 1000, 2);

      if (isset($timers[$name]['time'])) {
        $diff += $timers[$name]['time'];
      }
      return $diff;
    }
  }

  function variable_get($name, $default) {
    global $conf;

    return isset($conf[$name]) ? $conf[$name] : $default;
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Committed some code for cleaning this up.

mikeytown2’s picture

In a soon to be committed patch #1697244-3: Connection refused by destination. Write. curl works I eliminated the calls to all timer_* functions and call microtime() directly as this was identified as a slow point in the code. So all said and done, eventually the only thing one needs to define is variable_get(). And for this one function I'll probably create a wrapper and go from there.

mikeytown2’s picture

Status: Active » Needs review
FileSize
14.19 KB

Attached patch should allow for this. Still needs more testing though.

mikeytown2’s picture

Status: Needs review » Fixed
FileSize
15.13 KB

The following patch has been applied.

Fidelix’s picture

Are there any known downsides when using this, Mike? If not, this would be VERY welcome.

Thanks for the amazing work!

mikeytown2’s picture

Caveats if your using this on a Drupal site but with just the database bootstrap:
D7 only - Background operations (httprl_queue_background_callback()) will not work because lock.inc is not available in D7 (it is available in D6). Best bet is to to bootstrap up to DRUPAL_BOOTSTRAP_VARIABLES or include lock.inc manually on D7.

Caveats if your using this on a non Drupal site OR a Drupal site but without any Drupal bootstrap:
All of the above plus, errors will not be translated, in the options setting referrer = TRUE will not work, variables that are needed to overwrite the defaults should be placed in the $conf global (things like proxy settings).

Also this patch has been committed, I missed one function call :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.