Closed thomasplevy closed 2 years ago
@thomasplevy yeah the problem is this one: https://github.com/gocodebox/lifterlms/issues/909
I think we then have to treat here only this case:
EG: If I leave the price empty for a free plan (by excluding the key from the payload) I get this error.
I actually already accounted for this kind of errors: https://github.com/gocodebox/lifterlms-rest/blob/1.0.0-beta.23/includes/server/class-llms-rest-access-plans-controller.php#L611
But I must've done something wrong. :D
Yeah, the issue was a strict type comparison one, the access plan's price
is a float
, and I was comparing it to the int
0
.
Reproduction Steps
title
property.price
property from the body of the API request.Example payload:
Expected Behavior
Actual Behavior
Error Messages / Logs
Notes
I encountered this while developing the react-powered UI for managing access plans. This is easy enough to work around but ideally we shouldn't have to provide the price with every update request.
On closer inspection
This problem arises when not supplying the price for a free access plan or when supplying the existing price on paid access plans.
EG: If I leave the price empty for a free plan (by excluding the key from the payload) I get this error.
With a paid plan, if I specify the existing plan amount I also get this error.
This leads me to believe that this is actually an issue we've previously identified with regards to how we return
false
from the core postmodel class when updating meta data (and the value is unchanged). This is treated as an error by the rest api since there's no way to disambiguate between a false response that means NO CHANGE MADE and false response resulting from an error.