Skip to content

Not working with Route:cache #64

Open

Description

@Jaspur

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

Activity

  1. CaddyDz commented on Jun 8, 2020

    @CaddyDz
    Contributor

    Having the same issue

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

  2. CaddyDz commented on Jun 8, 2020

    @CaddyDz
    Contributor

    Issue exists since #25

  3. CaddyDz commented on Jun 8, 2020

    @CaddyDz
    Contributor

    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

  4. simonfunk commented on May 4, 2021

    @simonfunk

    I have the same issue, is there a fix?

  5. keizah7 commented on Jan 3, 2022

    @keizah7

    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))
    
  6. arhitektorr commented on Aug 10, 2022

    @arhitektorr

    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

  7. voidgraphics commented on Aug 10, 2022

    @voidgraphics
    Member

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

  8. arhitektorr commented on Aug 10, 2022

    @arhitektorr
  9. voidgraphics commented on Aug 10, 2022

    @voidgraphics
    Member

    @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

  10. arhitektorr commented on Oct 11, 2022

    @arhitektorr
  11. jahvi commented on Aug 24, 2023

    @jahvi

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

  12. aurelien-ci commented on Sep 29, 2023

    @aurelien-ci

    I have the same issue

  13. jolora commented on Jan 2, 2024

    @jolora

    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.

  14. toonvandenbos commented on May 13, 2024

    @toonvandenbos
    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!

  15. brightlabscomau commented on Nov 12, 2024

    @brightlabscomau

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions