1
votes
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.

2
Could you share sample php code that can reproduce this issue? (of-course without your clientID/clientSecret and other private/confidential info) - Pavlo - Podio
I can reproduce it by running \PodioApp::get($app); where $app is one of... 19641970, 19641961, 18706934, for example. If you create an array that is each of those apps, running the app::get call 50 times, you'll be able to reproduce the error. I've tested with multiple user access_tokens accounts fwiw. Thank you! - NathanL

2 Answers

1
votes

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
votes

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.