nikic / FastRoute

Fast request router for PHP
Other
5.12k stars 445 forks source link

Have a way to know the cache file is up to date #224

Closed williamdes closed 3 years ago

williamdes commented 4 years ago

Hi,

At phpMyAdmin we have issues like https://github.com/phpmyadmin/phpmyadmin/issues/16443 and https://github.com/phpmyadmin/phpmyadmin/issues/16412 that are based on the fast the code below did generate a cache file and a new route has been added. https://github.com/phpmyadmin/phpmyadmin/blob/3c0bb96e5d52fe19dccd4455a61297f114833e86/libraries/classes/Routing.php#L20 If the cache file exists and a new route is added, nothing happens and the end user has to debug a 404 error in the end..

I would like a way to serialize the return static function (RouteCollector $routes): void { data and have a hash of it. If the hash changes, do something: remove the file or do action X so the cache is renewed.

Any idea @nikic ?

williamdes commented 3 years ago

Hi @nikic Did you miss the notification for this issue ?

burzum commented 3 years ago

@williamdes he handed the maintainance of the project over to @lcobucci.

I would have to look into this further but I think you can't do that because the routes might include callables which aren't serializeable.

williamdes commented 3 years ago

I would have to look into this further but I think you can't do that because the routes might include callables which aren't serializeable.

Thank you for your response, can I still have the option and ban the use of callables in the phpMyAdmin routing declaration ?

williamdes commented 3 years ago

I am closing this, as I copied the function and re-wrote it with two flags. One for skipCaching and one for isWriteable. See: https://github.com/phpmyadmin/phpmyadmin/commit/778d916adfa21e662e4461aa960d7909278569fb