You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewWordpressCrowdSecBouncerException('Unable to connect Memcached.'.
87
+
' Please fix the Memcached DSN or select another cache technology.');
88
+
break;
89
+
90
+
caseCROWDSEC_CACHE_SYSTEM_REDIS:
91
+
thrownewWordpressCrowdSecBouncerException('Unable to connect Redis.'.
92
+
' Please fix the Redis DSN or select another cache technology.');
93
+
default:
94
+
thrownewWordpressCrowdSecBouncerException('Unable to connect the cache system: '.$e->getMessage());
95
+
}
96
+
}
97
+
67
98
$message = __('Cache system changed. Previous cache data has been cleared.');
99
+
} catch (WordpressCrowdSecBouncerException$e) {
100
+
}
68
101
69
-
// Update wp-cron schedule if stream mode is enabled
70
-
if ((bool) get_option('crowdsec_stream_mode')) {
71
-
$bouncer = getBouncerInstance($input); // Reload bouncer instance with the new cache system
72
-
$result = $bouncer->warmBlocklistCacheUp();
73
-
$message .= __(' As the stream mode is enabled, the cache has just been warmed up, '.($result > 0 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
74
-
scheduleBlocklistRefresh();
102
+
try {
103
+
// Reload bouncer instance with the new cache system and so test if dsn is correct.
104
+
getCacheAdapterInstance($input);
105
+
try {
106
+
// Try the adapter connection (Redis or Memcached will crash if the connection is incorrect)
//Update wp-cron schedule if stream mode is enabled
119
+
if ((bool) get_option('crowdsec_stream_mode')) {
120
+
$bouncer = getBouncerInstance($input); // Reload bouncer instance with the new cache system
121
+
$result = $bouncer->warmBlocklistCacheUp();
122
+
$message = __('As the stream mode is enabled, the cache has just been warmed up, '.($result > 0 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
0 commit comments