jamesmills / laravel-timezone

Enable user Timezones in your application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This cache store does not support tagging.

marvinhosea opened this issue · comments

This cache store does not support tagging.

Hi,

I am not aware that this package used the cache. Are you sure it's not something else which is causing this error?

This usually happens when you try and use something which ads tagging to cache but you have your cache settings to use file (which does not support tagging). I usually just use Redis for caching which solves this issue.

James

I'm getting this issue as well. It looks like it's being caused by something in the Torann\GeoIP\Cache's __construct method.

Here's the full error log:

BadMethodCallException thrown with message "This cache store does not support tagging."

Stacktrace:
#73 BadMethodCallException in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Cache/Repository.php:485
#72 Illuminate\Cache\Repository:tags in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php:356
#71 Illuminate\Cache\CacheManager:__call in /home/vagrant/code/vendor/torann/geoip/src/Cache.php:32
#70 Torann\GeoIP\Cache:__construct in /home/vagrant/code/vendor/torann/geoip/src/GeoIP.php:91
#69 Torann\GeoIP\GeoIP:__construct in /home/vagrant/code/vendor/torann/geoip/src/GeoIPServiceProvider.php:38
#68 Torann\GeoIP\GeoIPServiceProvider:Torann\GeoIP\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/Container.php:787
#67 Illuminate\Container\Container:build in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/Container.php:667
#66 Illuminate\Container\Container:resolve in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/Container.php:615
#65 Illuminate\Container\Container:make in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:757
#64 Illuminate\Foundation\Application:make in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:121
#63 app in /home/vagrant/code/vendor/torann/geoip/src/helpers.php:14
#62 geoip in /home/vagrant/code/vendor/jamesmills/laravel-timezone/src/Listeners/Auth/UpdateUsersTimezone.php:18
#61 JamesMills\LaravelTimezone\Listeners\Auth\UpdateUsersTimezone:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:366
#60 call_user_func_array in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:366
#59 Illuminate\Events\Dispatcher:Illuminate\Events\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:196
#58 Illuminate\Events\Dispatcher:dispatch in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php:603
#57 Illuminate\Auth\SessionGuard:fireLoginEvent in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php:421
#56 Illuminate\Auth\SessionGuard:login in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php:355
#55 Illuminate\Auth\SessionGuard:attempt in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php:82
#54 App\Http\Controllers\Auth\LoginController:attemptLogin in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php:45
#53 App\Http\Controllers\Auth\LoginController:login in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#52 call_user_func_array in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#51 Illuminate\Routing\Controller:callAction in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
#50 Illuminate\Routing\ControllerDispatcher:dispatch in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219
#49 Illuminate\Routing\Route:runController in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176
#48 Illuminate\Routing\Route:run in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php:680
#47 Illuminate\Routing\Router:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#46 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/app/Http/Middleware/RedirectIfAuthenticated.php:24
#45 App\Http\Middleware\RedirectIfAuthenticated:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#44 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#43 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
#42 Illuminate\Routing\Middleware\SubstituteBindings:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#41 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#40 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:75
#39 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#38 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#37 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
#36 Illuminate\View\Middleware\ShareErrorsFromSession:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#35 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#34 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:56
#33 Illuminate\Session\Middleware\StartSession:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#32 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#31 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
#30 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#29 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#28 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
#27 Illuminate\Cookie\Middleware\EncryptCookies:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#26 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#25 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#24 Illuminate\Pipeline\Pipeline:then in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php:682
#23 Illuminate\Routing\Router:runRouteWithinStack in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php:657
#22 Illuminate\Routing\Router:runRoute in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php:623
#21 Illuminate\Routing\Router:dispatchToRoute in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Router.php:612
#20 Illuminate\Routing\Router:dispatch in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
#19 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#18 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/fideloper/proxy/src/TrustProxies.php:57
#17 Fideloper\Proxy\TrustProxies:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#16 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#15 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
#14 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#13 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#12 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
#11 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#9 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
#8 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#7 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#6 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
#5 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
#4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#3 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#2 Illuminate\Pipeline\Pipeline:then in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
#1 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
#0 Illuminate\Foundation\Http\Kernel:handle in /home/vagrant/code/public/index.php:55

And my cache.php config is setting the default to file.

I've found that there is a geoip.php config file on the Torann\GeoIP package.
If I duplicate that into my own config directory and change this line:

'cache_tags' => ['torann-geoip-location'],

To this:

'cache_tags' => null,

It stops the error being thrown.

I'm not sure if this is a good way of doing it, but it's a temporary fix at least.
Is there any way that the error can be resolved in your package?

ah, yes!

I should probably have included a little more detailed information about the underlying package which does the timezone lookup! I rely on the torann/geoip (http://lyften.com/projects/laravel-geoip/) package to do the GeoIP lookup. This allows me to get the TimeZone of the user based on their location. It's the torann/geoip package which requires you to use a cache store which supports tagging.

By default, Laravel will use the 'file' cache driver (https://github.com/laravel/laravel/blob/master/config/cache.php#L21) but this does not support tagging (https://laravel.com/docs/5.8/cache#cache-tags).

As @GreenImp has suggested the best thing to do is to publish the torann/geoip config file by running

php artisan vendor:publish --provider="Torann\GeoIP\GeoIPServiceProvider" --tag=config

and then update the cache_tags to null

 /*
    |--------------------------------------------------------------------------
    | Cache Tags
    |--------------------------------------------------------------------------
    |
    | Cache tags are not supported when using the file or database cache
    | drivers in Laravel. This is done so that only locations can be cleared.
    |
    */

    'cache_tags' => null,

The only thing that this will prevent you from doing is being able to flush the cache and delete only those cache items linked to the geopip lookup.

I have updated the README with some additional information around this.

Thank you.

Fab, thanks for the explanation as well.

I found that changing file to array also solves the problem, but what are the pros/cons of using array vs. setting cache_tags to null? Thanks!