diff --git a/controllers/ApiController.php b/controllers/ApiController.php index bce5fa3c..b02bb4e0 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -99,6 +99,7 @@ public function init($extra) { }); } + register_shutdown_function(array($this, 'finishConcurrentRequest')); register_shutdown_function(array($this, 'checkDBTransactionState')); register_shutdown_function(array($this, 'logTotalRequestTime')); register_shutdown_function(array($this, 'checkForFatalError')); @@ -1164,10 +1165,6 @@ protected function redirect($url, $httpCode=302) { protected function end() { - if (Z_RequestLimiter::isConcurrentRequestActive()) { - Z_RequestLimiter::finishConcurrentRequest(); - } - if ($this->profile && $this->currentRequestTime() > $this->timeLogThreshold) { Zotero_DB::profileEnd($this->objectLibraryID, true, $this->uri); } @@ -1388,6 +1385,11 @@ public function handleError($no, $str, $file, $line) { $this->handleException($e); } + public function finishConcurrentRequest() { + if (Z_RequestLimiter::isConcurrentRequestActive()) { + Z_RequestLimiter::finishConcurrentRequest(); + } + } public function checkDBTransactionState($noLog = false) { if (Zotero_DB::transactionInProgress()) {