The audiobooks API endpoint returns a 500 Internal Server Error when both title and author parameters are provided together.
Steps to Reproduce
Works (title only):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023"
Returns 200 with correct data
Fails (title + author):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023&author=Various"
Returns 500 Internal Server Error
Suspected Cause
In application/libraries/Librivox_API.php, the function _build_author_project_id_list() returns 0 (integer) when no matching author is found:
return (empty($project_ids)) ? 0 : $project_ids;
This value is then passed to where_in():
$this->db->where_in('p.id', $project_id_list);
CodeIgniter's where_in() expects an array, not an integer, which may cause the error.
Suggested Fix
return (empty($project_ids)) ? [] : $project_ids;
And add a check in _build_data_set() to skip the where_in clause if the array is empty.
The audiobooks API endpoint returns a 500 Internal Server Error when both title and author parameters are provided together.
Steps to Reproduce
Works (title only):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023"
Returns 200 with correct data
Fails (title + author):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023&author=Various"
Returns 500 Internal Server Error
Suspected Cause
In application/libraries/Librivox_API.php, the function _build_author_project_id_list() returns 0 (integer) when no matching author is found:
CodeIgniter's where_in() expects an array, not an integer, which may cause the error.
Suggested Fix
return (empty($project_ids)) ? [] : $project_ids;And add a check in _build_data_set() to skip the where_in clause if the array is empty.