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

Not working with Route:cache #64

Open
Jaspur opened this issue May 19, 2020 · 15 comments
Open

Not working with Route:cache #64

Jaspur opened this issue May 19, 2020 · 15 comments

Comments

@Jaspur
Copy link

Jaspur commented May 19, 2020

When php artisan route:cache ran, it's not working:

[2020-05-19 16:22:37] production.ERROR: Argument 1 passed to Whitecube\NovaPage\Pages\StaticResource::__construct() must be an instance of Whitecube\NovaPage\Pages\Template, instance of Whitecube\NovaPage\Pages\Manager given, called in /home/forge/foobar.nl/vendor/laravel/nova/src/Http/Requests/InteractsWithResources.php on line 65 {"userId":1,"exception":"[object] (TypeError(code: 0): Argument 1 passed to Whitecube\\NovaPage\\Pages\\StaticResource::__construct() must be an instance of Whitecube\\NovaPage\\Pages\\Template, instance of Whitecube\\NovaPage\\Pages\\Manager given, called in /home/forge/foobar.nl/vendor/laravel/nova/src/Http/Requests/InteractsWithResources.php on line 65 at /home/forge/foobar.nl/vendor/whitecube/nova-page/src/Pages/StaticResource.php:52)
[stacktrace]

@Nyratas

@CaddyDz
Copy link
Contributor

CaddyDz commented Jun 8, 2020

Having the same issue

Whitecube\NovaPage\Exceptions\TemplateNotFoundException
NovaPage Template for "route.about" not found.

@CaddyDz
Copy link
Contributor

CaddyDz commented Jun 8, 2020

Issue exists since #25

@CaddyDz
Copy link
Contributor

CaddyDz commented Jun 8, 2020

Looking at the cached routes in bootstrap/cache/routes-v7.php
I found this

'/about' => 
array (
0 => 
array (
	0 => 
	array (
	'_route' => 'about',
	),
),
),
'/explanations' => 
array (
0 => 
array (
	0 => 
	array (
	'_route' => 'generated::IiVW6TNc537ZRvuv',
	),
),

The _route array key should have a generate value, instead it's just the route name

@simonfunk
Copy link

I have the same issue, is there a fix?

@keizah7
Copy link

keizah7 commented Jan 3, 2022

I have this issue with route caching

[2022-01-03 10:33:17] local.ERROR: Whitecube\NovaPage\Pages\StaticResource::__construct(): Argument #1 ($resource) must be of type Whitecube\NovaPage\Pages\Template, Whitecube\NovaPage\Pages\Manager given, called in /Users/arturas/code/Freelance/jammi/nova/src/Http/Requests/InteractsWithResources.php on line 65 {"userId":9,"exception":"[object] (TypeError(code: 0): Whitecube\\NovaPage\\Pages\\StaticResource::__construct(): Argument #1 ($resource) must be of type Whitecube\\NovaPage\\Pages\\Template, Whitecube\\NovaPage\\Pages\\Manager given, called in /Users/arturas/code/Freelance/jammi/nova/src/Http/Requests/InteractsWithResources.php on line 65 at /Users/arturas/code/Freelance/jammi/vendor/whitecube/nova-page/src/Pages/StaticResource.php:52)
[stacktrace]
#0 /Users/arturas/code/Freelance/jammi/nova/src/Http/Requests/InteractsWithResources.php(65): Whitecube\\NovaPage\\Pages\\StaticResource->__construct(Object(Whitecube\\NovaPage\\Pages\\Manager))

@arhitektorr
Copy link

I got the same problem. Why don't the creators fix this problem? You have found a solution. By clearing the cache of the mof router, the problem does not disappear
444

@voidgraphics
Copy link
Member

@Sliper959595 If you have a solution, please send a pull request.

@arhitektorr
Copy link

arhitektorr commented Aug 10, 2022 via email

@voidgraphics
Copy link
Member

voidgraphics commented Aug 10, 2022

@Sliper959595 there is no known solution to this problem at this time, except not using route caching. If you do find a solution or workaround, please consider sharing your findings with others in this thread, or better yet, opening a pull request with a fix. Thanks

@arhitektorr
Copy link

arhitektorr commented Oct 11, 2022 via email

@jahvi
Copy link

jahvi commented Aug 24, 2023

As a workaround avoid caching routes for now, not ideal but at least it works.

@aurelien-ci
Copy link

I have the same issue

@jolora
Copy link

jolora commented Jan 2, 2024

Curious if anyone has any idea about how to provide a longer term fix for this please? I'd like to apply route caching on my application but doing so breaks this package.

@toonvandenbos
Copy link
Member

Hello there, sorry for the delay.

I published a fix that should have fixed this issue... At least, everything seems to be working fine on my local testing app. Could you please confirm? Thanks!

@brightlabscomau
Copy link

brightlabscomau commented Nov 12, 2024

We needed a fix for this, as this library has been used extensively in one of our projects.. and we have hundreds of other routes that need to be cached.

I also couldn't locate the fix that @toonvandenbos mentioned above..

I resolved this by adding my own Middleware, instead of using Whitecube\NovaPage\Http\Middleware\LoadPageForCurrentRoute.. I duplicated the class, and replaced the handle() method with the following:

public function handle(Request $request, Closure $next)
{
    try {
        $this->page->loadForRoute($request->route());
    } catch (TemplateNotFoundException) {
        $this->page->getRepository()->register('route', $request->route()->getName(), $request->route()->template());
        $this->page->loadForRoute($request->route());
        return $next($request);
    }

    return $next($request);
}

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

No branches or pull requests