storm icon indicating copy to clipboard operation
storm copied to clipboard

Ensure cached routes are loaded on app boot

Open bennothommo opened this issue 3 years ago • 8 comments

Simplifies the routing service provider and checks if routes are cached. If so, this will load the cached routes on the app being booted.

Fixes https://github.com/wintercms/winter/issues/666

bennothommo avatar Sep 02 '22 08:09 bennothommo

Do we not need the UrlGenerator override stuff in place for our functionality to take effect?

LukeTowers avatar Sep 03 '22 07:09 LukeTowers

Don't believe so :)

bennothommo avatar Sep 03 '22 08:09 bennothommo

Tested this one. It appears that routes provided by a plugin are not being cached (e.g. vendor/plugin/routes.php)

canthis avatar Sep 03 '22 17:09 canthis

@canthis I don't believe they've ever been cached, or picked up for that matter, since it's routed through the main Backend Controller class.

bennothommo avatar Sep 05 '22 14:09 bennothommo

@bennothommo those are different, @canthis is talking about routes that are explicitly registered by the plugins' routes.php file.

LukeTowers avatar Sep 06 '22 06:09 LukeTowers

@LukeTowers @canthis happy to tackle that in another PR, this one should at least fix the immediate issue of the site breaking if someone uses route:cache.

bennothommo avatar Sep 06 '22 06:09 bennothommo

@bennothommo I still don't understand why we need to remove the UrlGenerator override code, could you explain that?

LukeTowers avatar Oct 18 '22 20:10 LukeTowers

@LukeTowers I thought our extended UrlGenerator just adds the static method buildUrl, so it wouldn't matter, but I just realised that we also overwrite the to method. So I'll probably have to add that block back into the service provider.

bennothommo avatar Oct 19 '22 11:10 bennothommo

@bennothommo are you still interested in finishing this PR?

LukeTowers avatar Nov 29 '22 20:11 LukeTowers

@bennothommo Thank You

This fixes problem with cached routes, but similar problem occurs with configuration that is not available from the cache.

php artisan config:cache or php artisan optimize Winter 1.2.1 or dev-develop

ArturCiolkiewicz avatar Apr 12 '23 12:04 ArturCiolkiewicz

Thanks for letting us know @ArturCiolkiewicz - could you post that as a separate issue for us? I'll be able to sort it out within a couple of days.

bennothommo avatar Apr 13 '23 02:04 bennothommo