Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Add class_exists check for Spark's subscribed default alias Middleware #50489

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

akr4m
Copy link
Contributor

@akr4m akr4m commented Mar 12, 2024

Fix ReflectionException for Missing Spark Middleware in Laravel

This PR addresses an issue where Laravel was attempting to load the Spark\Http\Middleware\VerifyBillableIsSubscribed middleware, which does not exist by default in Laravel 11. The alias subscribed was mistakenly added to the default middleware aliases in Middleware.php, leading to a ReflectionException when the framework tried to resolve it.

When Laravel attempts to utilize the subscribed middleware, it triggers a ReflectionException because the Spark\Http\Middleware\VerifyBillableIsSubscribed class does not exist. This error disrupts the functionality of applications running on Laravel 11 that rely on the default middleware stack.

The PR removes the subscribed alias from the defaultAliases() method in Middleware.php, preventing Laravel from attempting to load a non-existent middleware class. This change ensures that the application can run without encountering a fatal error due to the missing class.

@akr4m akr4m changed the title Removed Spark's subscribed default alias Middleware [11.x] Removed Spark's subscribed default alias Middleware Mar 12, 2024
@nunomaduro
Copy link
Member

Can you share the exact error you faced in your application? A screenshot of the browser or console?

@akr4m
Copy link
Contributor Author

akr4m commented Mar 12, 2024

Can you share the exact error you faced in your application? A screenshot of the browser or console?

image

@taylorotwell
Copy link
Member

I believe this may be from your static analysis tool or something. How can I recreate this error in a fresh L11 installation?

@taylorotwell
Copy link
Member

Regardless, it shouldn't be removed. A class_exists check can be added.

@akr4m
Copy link
Contributor Author

akr4m commented Mar 12, 2024

Thank you.
In addition I'm using Laravel IDE Helper.
As it was installed I was noticed that error log

@akr4m
Copy link
Contributor Author

akr4m commented Mar 12, 2024

Regardless, it shouldn't be removed. A class_exists check can be added.

Should I add class_exists check?

@taylorotwell
Copy link
Member

Sure.

@taylorotwell taylorotwell merged commit eac3418 into laravel:11.x Mar 12, 2024
28 checks passed
@driesvints driesvints changed the title [11.x] Removed Spark's subscribed default alias Middleware [11.x] Add class_exists check for Spark's subscribed default alias Middleware Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants