From d421978c11d1537c3a83b1648f8a5ad4b9b53421 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 10 Jul 2017 11:24:43 +0300 Subject: [PATCH] Register a shutdown function for concurrent request finishing --- controllers/ApiController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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()) {