Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
}
}
Comment | File | Size | Author |
---|---|---|---|
#6 | httprl-1826624-6-allow-background-calls-sooner.patch | 535 bytes | mikeytown2 |
#4 | httprl-1826624-4-independent-operation.patch | 15.13 KB | mikeytown2 |
#3 | httprl-1826624-3-independent-operation.patch | 14.19 KB | mikeytown2 |
#1 | httprl-1826624-1-cleanup-bootstrap-code.patch | 2.76 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedCommitted some code for cleaning this up.
Comment #2
mikeytown2 CreditAttribution: mikeytown2 commentedIn 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.
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedAttached patch should allow for this. Still needs more testing though.
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedThe following patch has been applied.
Comment #5
Fidelix CreditAttribution: Fidelix commentedAre there any known downsides when using this, Mike? If not, this would be VERY welcome.
Thanks for the amazing work!
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedCaveats 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 :)