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

View composer namespaced wildcards no longer work #44634

Closed
jasonvarga opened this issue Oct 18, 2022 · 7 comments · Fixed by #44636
Closed

View composer namespaced wildcards no longer work #44634

jasonvarga opened this issue Oct 18, 2022 · 7 comments · Fixed by #44636
Assignees
Labels

Comments

@jasonvarga
Copy link
Contributor

  • Laravel Version: 9.36.0
  • PHP Version: 8.1.6
  • Database Driver & Version: N/A

Description:

Using a view composer with a namespaced wildcard no longer works as of 9.36.0. Likely due to #44487 since it's all about views.

public function boot()
{
    $this->loadViewsFrom(resource_path('namespaced'), 'namespaced');

    View::composer('namespaced::*', fn ($view) => $view->with('foo', 'bar'));
}
{{ $foo }}
Undefined variable $foo

Using a complete wildcard still works. View::composer('*', ...)
It's just the namespaced version that doesn't. View::composer('namespace::*', ...)

Steps To Reproduce:

Here's a GitHub repo with the issue reproduced. Link to commit that adds the problematic bits:
https://github.com/jasonvarga/laravel-view-composer-issue/commit/1548cefdba11aa2c660eb2aab6eb5b5fef2d1958

@jasonvarga
Copy link
Contributor Author

I'll take a stab at a PR.

@KennedyTedesco
Copy link
Contributor

Yeah, I can confirm the issue. We need to work a bit more on shouldCallComposers. Good luck on the PR! =D

@jasonvarga
Copy link
Contributor Author

I had a feeling it would be much faster for Nuno. 🤣

@nunomaduro
Copy link
Member

nunomaduro commented Oct 18, 2022

@jasonvarga @KennedyTedesco Can you test if the changes I've made fix the issue you were having in your application? It does fix the issue on the application you have prepared on the issue.

@KennedyTedesco
Copy link
Contributor

@nunomaduro My application has lots of custom namespaces and composers using wildcards, and with your fix, everything works fine again. Thank you!

@jasonvarga
Copy link
Contributor Author

Yup, fixes it for us too. Thanks @nunomaduro

@jasonvarga
Copy link
Contributor Author

Thank you for the speedy turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants