From 0ffbf3274a695273ca1cdf04733dcfa1bb0cbeda Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 23 Mar 2021 16:34:21 +0100 Subject: [PATCH] API::search method: set timeout according to the number of objects in response --- src/includes/routes.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/includes/routes.php b/src/includes/routes.php index 4c11bd64..cc94bf6a 100644 --- a/src/includes/routes.php +++ b/src/includes/routes.php @@ -1626,6 +1626,13 @@ function handle_api_LSobject_search($request) { $data['page'] = $page['nb']; $data['nbPages'] = $page['nbPages']; } + + // Reset & increase time limit: allow one seconds by object to handle, + // with a minimum of 30 seconds + $timeout = count(($all?$entries:$page['list'])); + set_time_limit(($timeout>30?$timeout:30)); + + // Handle objects foreach(($all?$entries:$page['list']) as $obj) { $data['objects'][$obj -> dn] = array( 'name' => $obj -> displayName,