-
Notifications
You must be signed in to change notification settings - Fork 12
Undefined array key 0 in RW::parseError() when results is an empty array #98
Copy link
Copy link
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem right
Description
RW::parseError() crashes with Undefined array key 0 when the API returns a successful response with an empty results array.
This happens because parseError() is called from RO::parseResponse() for every response that contains a success key (line 1264 of RO.php), regardless of whether the operation actually failed. Some API endpoints (e.g., automaticke-parovani) return a response like:
{
"winstrom": {
"@version": "1.0",
"success": "true",
"stats": {
"created": "0",
"updated": "0",
"deleted": "0",
"skipped": "0",
"failed": "0"
},
"results": []
}
}
In parseError(), the condition on line 170 of RW.php checks array_key_exists(0, $responseDecoded['results']). When $responseDecoded['results'] is empty, this returns false, and the code falls into the else branch (line 183) which immediately tries to access $responseDecoded['results'][0]['result'] - the very key that was just confirmed to not exist.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem right