Podio error when getting apps

2019-07-27 09:31发布

问题:

Error
ErrorException: array_merge(): Argument #1 is not an array in /my/server/vendor/podio/podio-php/lib/PodioObject.php:200
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'array_merge(): ...', '/my/server/...', 200, Array)
#1 /my/server/vendor/podio/podio-php/lib/PodioObject.php(200): array_merge(NULL, Array)
#2 /my/server/vendor/podio/podio-php/models/PodioApp.php(39): PodioObject::member(Object(PodioResponse))
#3 /my/path.php(413): PodioApp::get(xxxxxxx)

This appears to be a bug with the Podio PHP SDK or Podio API. The json_response (which is causing the array_merge error) is null, yet the http response is 200. I cannot get it to occur regularly, however it occurs roughly 10% of the time on script that is running 30~ of these calls. I can run the GetApp call directly from the documentation just fine.

I know it's an error with the responses because my script breaks at different places on each rerun depending on which data hasn't been loaded from the API correctly.

Test 1: Exception at line 344 as the result of $app1 being null

Test 2: Exception at line 814 as the result of $app3 being null

etc...

This is a script that was not modified and has been in place for over 6 months, but stopped working sometime last week.

EDIT: I've also confirmed that the same error occurs with cURL, so it isn't an SDK-specific issue.

回答1:

This intermittent errors should not be happening anymore :)
Unless your network connection is unstable or choppy.

Anyway it's good to have proper handling for network-dependent calls (like any Podio API call). I can only suggest that all Podio API calls should go through queueing mechanism that will allow retry in case if network is unstable or Podio is on maintenance (as example).



回答2:

The same intermittent error is occurring for us also. Since the TLS change was rolled out.

A temporary workaround is to wrap calls in a do while loop to retry when there are errors.

E.g.

// Get item from API
$attempts = 0;
do {
    try {
        $item = PodioItem::get($itemId);
    } catch (\Exception $e) {
        $attempts++;
        Log::error("PodioItemGetFailure #" . $attempts . ". " . $e->getMessage());
        sleep(3);
        continue;
    }
    break;
} while ($attempts < 3);

This is a bit nasty, so hopefully we have a resolution on the causes on Podio's side soon.



标签: php podio