xero-php icon indicating copy to clipboard operation
xero-php copied to clipboard

loadByGuid returns random resource if $guid is null

Open paprikati opened this issue 4 years ago • 4 comments

If a user supplies a null value for $guid or $guids for the loadByGuid and loadByGuids methods, the code pulls a page of models, and returns the first one, effectively returning a random model. The code needs to explicitly check that this parameter is not null, before continuing.

I have a fix in a branch - if you give me permissions I can open a PR

paprikati avatar Mar 24 '20 11:03 paprikati

@paprikati What do you propose happens if null is passed? For BC, all I can think is throwing a NotFoundException? For loadByGuids, that can just return an empty array.

You can make a PR as it stands, not sure what permissions you're after.

calcinai avatar Mar 24 '20 19:03 calcinai

Weird - I was struggling to create a branch. Will try again. Yeah the code I wrote throws a NotFoundException

paprikati avatar Mar 24 '20 19:03 paprikati

I definitely can't create a branch - even in browser: image

can you invite me as a contributor?

paprikati avatar Mar 25 '20 10:03 paprikati

@paprikati You need to fork the repository and then (if you want) create a branch in your own fork. You can then make a PR from your fork to upstream (this repo).

Have a read of this

calcinai avatar Mar 25 '20 19:03 calcinai