routeros-api-php
routeros-api-php copied to clipboard
fix: handle empty parseResponse for nested script execution (issue #136)
Problem
When executing a RouterOS script that calls another script (/system/script/run), the response may contain empty data blocks. This causes Undefined array key 0 error at line 377 of Client.php because parseResponse() returns an empty array [].
Solution
- Replace inefficient double parseResponse() call with single call
- Use
!empty()andisset()checks to properly handle empty array responses - Add unit test for empty response edge case
Changes
- src/Client.php: Fixed rosario() method to handle empty parseResponse result
- tests/ClientTest.php: Added test_parseResponse_emptyArrayHandling() test
Testing
- PHP syntax validation passed
- Unit test added for the edge case
Fixes: #136