Gricenko Mihail Posted March 19, 2019 Share Posted March 19, 2019 Hello, please help me with next issue Let's imagine i have custom script which interacting with WHMCS... ( WHMCS 7.1.2 ) <?php define('CLIENTAREA', true); define('WHMCS_ROOT_DIR', dirname(dirname(__FILE__))); require WHMCS_ROOT_DIR . '/init.php'; $result = \localApi('GetOrders', array('userid' => $user_id, 'id' => $order_id), 'administrator'); long_running_function(); // runing about 10 minutes $result = \localApi('GetOrders', array('userid' => $user_id, 'id' => $order_id), 'administrator'); ?> It's abstract code to reproduce issue. Let's see what's happened. First call of "LocalApi" return "success" as expected But after "long_running_function" ends then second call of "LocalApi" return error with message "No matching admin user found" And console output says me next: "# PHP Warning: mysql_fetch_array() expects parameter to be resource, boolean was given. in /home/whmcs/web/public_html/includes/dbcompatfunctions.php on line 0" It's seems to be because mysql lost default connection after long time of waiting and "localApi" function can't get id of provided user. So how i can reestablish connection to continue use of "localApi" function? Using of before second call of localApi Capsule::connection()->reconnect(); has no effect 0 Quote Link to comment Share on other sites More sharing options...
Gricenko Mihail Posted March 22, 2019 Author Share Posted March 22, 2019 No ideas? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 23, 2019 Share Posted March 23, 2019 You can try Capsule::connection()->getPdo() IIRC to see if that will do a reconnect as it seems reconnect doesn't work but you will want to close the pdo before doing any other capsule queries as the pdo takes over and expects to be used from what I have seen. 0 Quote Link to comment Share on other sites More sharing options...
Gricenko Mihail Posted March 23, 2019 Author Share Posted March 23, 2019 5 hours ago, steven99 said: You can try Capsule::connection()->getPdo() IIRC to see if that will do a reconnect as it seems reconnect doesn't work but you will want to close the pdo before doing any other capsule queries as the pdo takes over and expects to be used from what I have seen. On 3/19/2019 at 8:32 PM, Gricenko Mihail said: Capsule::connection()->reconnect(); Working with Capsule::table() queries. But it's don't take any effect with \LocalApi function. I think \LocalApi code is not used Capsule:: inside 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.