Upgrade to latest OctoberCMS breaks APIs

Hi

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.

Any ideas are appreciated!

Hi @abenade

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:

Hi

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:

url = "/api/rolecats"
title = "View Roleplayer Categories API"

[roleCategories]

==

{{ dump(items) }}

{% if items %}

{% else %}

{% endif %}

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]

Hey @abenade

We may need to see the complete stack trace of the error to see what triggers it.

Hi

There are 10 stack traces and they’re not all the same. I think it would be too much information to post here, so I’ve e-mailed it to you.

Hi

This issue was caused by another plugin that used App::error(function($e) {}); I’ve deleted the plugin and the APIs are working now.

1 Like

Great! Yes, unfortunately this was a spot that Laravel broke and we couldn’t prevent it…

Glad to hear you got it solved.