Patreon / patreon-php

Interact with the Patreon API via OAuth
Apache License 2.0
145 stars 41 forks source link

auth without pledges: "0" doesn't exist in this resource. #50

Closed foohonpie closed 4 years ago

foohonpie commented 5 years ago

The readme example has a check for ($patron->has('relationships.pledges')) that can return true even if the patron hasn't pledged to the campaign in question. This causes the call inside that block to $patron->relationship('pledges')->get(0)->resolve($patron_response) to hit a 500 error with the following message:

PHP Fatal error:  Uncaught exception 'Art4\JsonApiClient\Exception\AccessException' with message '"0" doesn't exist in this resource.'

The user I tested with has pledges for several other campaigns, but none for the one being authed against. I believe this means that either or both:

  1. the ->has('relationships.pledges') can return a false positive
  2. the readme example should be updated to avoid this case

Please let me know if any other info would be useful.

Thanks!

sustained commented 5 years ago

Is this the same as the issue I encountered here (just to ensure that my understanding of what is happening is correct)?