I upgraded a site to the latest October CMS and all my APIs stopped working. I get a Server 500 error and the error log shows:
Symfony\Component\ErrorHandler\Error\FatalError: Uncaught RuntimeException: The given Closure has no parameters. in […/public_html/vendor/laravel/framework/src/Illuminate/Support/Traits/ReflectsClosures.php:58]
RuntimeException: The given Closure has no parameters. in […/public_html/vendor/laravel/framework/src/Illuminate/Support/Traits/ReflectsClosures.php:58]
My APIs only have the code below which results in the above errors:
{% if items %}
{% do response({
data: items
}) %}
{% else %}
{% do response({
data: {}
}) %}
{% endif %}
When I dd($this->page[‘items’]) in my components it works, but if I {{ dump(items) }} in the API page I also get these errors.
Check your codebase for a call to App::error(function(){ }). If this function has no parameter or type-hint, it can cause this error. Commenting out this line might help, or updating it to the latest specification in the docs will also fix it. Here’s a link:
I’ve checked my codebase and App::error(function(){ }) is not used anywhere. I narrowed the issue down a bit. This will display the array with 7 items:
But adding the responses result in a server 500 error:
url = "/api/rolecats"
title = "View Roleplayer Categories API"
[roleCategories]
==
{% if items %}
{% do response({
data: items
}) %}
{% else %}
{% do response({
data: {}
}) %}
{% endif %}
and the log displays:
(once) - Symfony\Component\ErrorHandler\Error\FatalError: Uncaught RuntimeException: The given Closure has no parameters. in […/public_html/vendor/laravel/framework/src/Illuminate/Support/Traits/ReflectsClosures.php:58]
(9 entries) - RuntimeException: The given Closure has no parameters. in […/public_html/vendor/laravel/framework/src/Illuminate/Support/Traits/ReflectsClosures.php:58]