Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on PodioItem->save() - Undefined index: value #167

Closed
GREPY opened this issue Jun 10, 2019 · 4 comments
Closed

Error on PodioItem->save() - Undefined index: value #167

GREPY opened this issue Jun 10, 2019 · 4 comments

Comments

@GREPY
Copy link

GREPY commented Jun 10, 2019

Hi, I'm using podio-php in Laravel project. And I have problem saving podio item from one my custom Registrations app. Items from other app can be saved without problem - but when I try to save Registration Podio Item previously fetched by get or get_basic function - it fails with error in library code.
This is the simplest code causing the issue:

$registration = PodioItem::get(1149458930);
//commented code - working with registration data...
$registration->save();

And error I get:

Undefined index: value - in /code/vendor/podio/podio-php/models/PodioItemField.php:1125 
Stack trace:
/code/vendor/podio/podio-php/models/PodioItemField.php:1125
/code/vendor/podio/podio-php/models/PodioItemField.php:1142
/code/vendor/podio/podio-php/models/PodioItemField.php:46
/code/vendor/podio/podio-php/lib/PodioObject.php:322
/code/vendor/podio/podio-php/models/PodioItem.php:85
/code/vendor/podio/podio-php/models/PodioItem.php:63
/code/app/Jobs/RegistrationConfirmJob.php:44

Of course, given ID is valid item_id from registration app. Before calling $registration->save(); I can successfully work with registration fields and relationships but the save function fails even if I comment out all the code between - so basically item is loaded and I try to save it without modification.

I found out that in PodioObject.php around line 322 there is suspicious block of code:

// TODO: This really should be moved to PodioCollection (should implement as_json)
//       and PodioItemFieldCollection for the special case
elseif (get_class($this->__attributes[$name]) === 'PodioItemFieldCollection') {
    $key = $item->external_id ? $item->external_id : (string)$item->field_id;
    $list[$key] = $item->as_json(false);
}

...but I have no idea what can I do since it looks like problem in library code and I don't want to modify it.
Can anyone help me with this? Thanks in advance.

@daniel-sc
Copy link
Member

Hi @GREPY,

thanks for reporting this - this really looks like a bug of this library!

To find the cause, it would be helpful, if you could share the (anonymized) raw json response from the item 1149458930 (or any other item that this can be reproduced with). You can access this via Podio::$last_response->body or by Podio::set_debug(true).

Thanks, Daniel

@GREPY
Copy link
Author

GREPY commented Jun 13, 2019

Thank you for your reaction
Here I attach the (anonymized) result of Podio::$last_response->body after fetching registration item.
hemis-podio-response.txt
Hope you can find the cause as soon as possible - since there are deadlines for this app to work correctly.

@daniel-sc
Copy link
Member

Hi @GREPY,
I could only reproduce this with version 4.3.0 but not with the latest version 4.4.0 - would you mind to check if it works for you with the latest version? If this error persists, please provide details on OS, PHP version etc.

@GREPY
Copy link
Author

GREPY commented Jun 13, 2019

Thank you, Daniel, it really works in latest version. I didn't notice there is new version 11 days old with new package name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants