Skip to content

Commit 3971387

Browse files
committed
Changed global cache tag to proper prefix
1 parent 95bc97d commit 3971387

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fix for `merge` bundling rule (#660)
55
- Fix for undefined variable exception under strict mode in `ufAlerts` (#809)
66
- Fix for site cache reset upon login (#828)
7+
- Changed global cache tag to proper prefix
78

89
## v4.1.15-alpha
910
- Refactor `Password` into a instantiable `Hasher` class, service, and `Password` facade (#827)
@@ -34,7 +35,7 @@
3435
- Change "remember me" text
3536
- Improve table tool buttons
3637
- Twig extensions now implement `Twig_Extension_GlobalsInterface` as required by https://twig.symfony.com/doc/2.x/advanced.html#id1 (#788)
37-
- Display element based on permissions for group list/info pages
38+
- Display element based on permissions for group list/info pages
3839
- Factor the admin user creation out of migrations and into its own Bakery command (See #778)
3940
- Bakery `clear-cache` command now clears Twig and router cache (Fix #750)
4041
- Add Russian translations
@@ -365,7 +366,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
365366
- Use Laravel's Schema interface to create tables and default rows, instead of constructing them with SQL
366367

367368
## v0.3.1.20
368-
- Added `pushAlert()`,`clearAlerts()` in `public/js/userfrosting.js` and updated `flashAlerts()`
369+
- Added `pushAlert()`,`clearAlerts()` in `public/js/userfrosting.js` and updated `flashAlerts()`
369370
- Revert changes to User::fresh() but leave comment regarding upgrading Eloquent
370371

371372
## v0.3.1.19
@@ -492,7 +493,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
492493
- [Theming](https://v3.userfrosting.com/components/#theming)
493494
- [Plugins](https://v3.userfrosting.com/components/#plugins)
494495

495-
## v0.2.1
496+
## v0.2.1
496497
- Implemented db-driven menu system. Menu items are pulled from the database, and can be modified via plugins.
497498
- Implemented backend templating of forms and tables via [Bootsole](https://github.com/alexweissman/bootsole).
498499

@@ -529,7 +530,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
529530
- Included better functions for sanitizing user input, validating user ip, generating csrf (cross-site request forgery) tokens - thanks to contributor @r3wt
530531

531532
## v0.1.3
532-
- Root account (user id = 1) : created upon installation, cannot be deleted or disabled.
533+
- Root account (user id = 1) : created upon installation, cannot be deleted or disabled.
533534
- Special color scheme for when logged in as root user.
534535
- Installer now guides user through creation of root account
535536
- Moved common JS and CSS includes to "includes.php"

app/sprinkles/account/src/Database/Models/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ public static function exists($value, $identifier = 'user_name', $checkDeleted =
210210
/**
211211
* Return a cache instance specific to that user
212212
*
213-
* @return Illuminate\Contracts\Cache\Store
213+
* @return \Illuminate\Contracts\Cache\Store
214214
*/
215215
public function getCache()
216216
{
217-
return static::$ci->cache->tags([static::$ci->config['cache.prefix'], '_u'.$this->id]);
217+
return static::$ci->cache->tags('_u'.$this->id);
218218
}
219219

220220
/**

app/sprinkles/core/src/Alert/CacheAlertStream.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function __construct($messagesKey, MessageTranslator $translator = null,
5050
/**
5151
* Get the messages from this message stream.
5252
*
53-
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
53+
* @return array An array of messages, each of which is itself an array containing 'type' and 'message' fields.
5454
*/
5555
public function messages()
5656
{
57-
if ($this->cache->tags([$this->config['cache.prefix'], "_s".session_id()])->has($this->messagesKey)) {
58-
return $this->cache->tags([$this->config['cache.prefix'], "_s".session_id()])->get($this->messagesKey) ?: [];
57+
if ($this->cache->tags('_s'.session_id())->has($this->messagesKey)) {
58+
return $this->cache->tags('_s'.session_id())->get($this->messagesKey) ?: [];
5959
} else {
6060
return [];
6161
}
@@ -68,7 +68,7 @@ public function messages()
6868
*/
6969
public function resetMessageStream()
7070
{
71-
$this->cache->tags([$this->config['cache.prefix'], "_s".session_id()])->forget($this->messagesKey);
71+
$this->cache->tags('_s'.session_id())->forget($this->messagesKey);
7272
}
7373

7474
/**
@@ -79,6 +79,6 @@ public function resetMessageStream()
7979
*/
8080
protected function saveMessages($messages)
8181
{
82-
$this->cache->tags([$this->config['cache.prefix'], "_s".session_id()])->forever($this->messagesKey, $messages);
82+
$this->cache->tags('_s'.session_id())->forever($this->messagesKey, $messages);
8383
}
8484
}

app/sprinkles/core/src/ServicesProvider/ServicesProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,18 @@ public function register(ContainerInterface $container)
159159
$path = $c->locator->findResource('cache://', true, true);
160160
$cacheStore = new TaggableFileStore($path);
161161
} elseif ($config['cache.driver'] == 'memcached') {
162-
$cacheStore = new MemcachedStore($config['cache.memcached']);
162+
// We need to inject the prefix in the memcached config
163+
$config = array_merge($config['cache.memcached'], ['prefix' => $config['cache.prefix']]);
164+
$cacheStore = new MemcachedStore($config);
163165
} elseif ($config['cache.driver'] == 'redis') {
164-
$cacheStore = new RedisStore($config['cache.redis']);
166+
// We need to inject the prefix in the redis config
167+
$config = array_merge($config['cache.redis'], ['prefix' => $config['cache.prefix']]);
168+
$cacheStore = new RedisStore($config);
165169
} else {
166170
throw new \Exception("Bad cache store type '{$config['cache.driver']}' specified in configuration file.");
167171
}
168172

169-
$cache = $cacheStore->instance();
170-
return $cache->tags($config['cache.prefix']);
173+
return $cacheStore->instance();
171174
};
172175

173176
/**

0 commit comments

Comments
 (0)