With the following code on a cron hook, I occasionally get "No matching admin user found" error message instead of the invoice I'm after.
$values["invoiceid"] = $data['whmcs_id'];
$invoice = localAPI('getinvoice', $values, get_admin_user());
(get_admin_user function just returns the admin user I have set in my module settings)
I'm using a cron task to add invoice payments for invoices and lately the amount of invoices I'm processing at the same time has been increasing.
This same piece of code worked properly up until now and the only ways I'm able to get around this error are:
Switch my function get_admin_user to return id instead of the admin username, but this fixed the problem only for a few days
Use a different admin account
Run my script through admin rather than on cron hook
However, switching the accounts isn't a proper fix and I need to be able to run my script through cron.
The admin user I'm using primarly for this has full permissions and it's account is active and the WHMCS version I'm using is 6.3.1.