Skip to content

Commit 6020f8f

Browse files
authored
Merge pull request #290 from codesnippetspro/louiswol94-patch-1
fix: object cache issues on settings page
2 parents 042ddd1 + e30a6fd commit 6020f8f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/php/settings/settings.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Code_Snippets\Welcome_API;
1212
use function Code_Snippets\clean_snippets_cache;
1313
use function Code_Snippets\code_snippets;
14+
use const Code_Snippets\CACHE_GROUP;
1415

1516
const CACHE_KEY = 'code_snippets_settings';
1617
const OPTION_GROUP = 'code-snippets';
@@ -79,7 +80,7 @@ function are_settings_unified(): bool {
7980
* @return array<string, array<string, mixed>>
8081
*/
8182
function get_settings_values(): array {
82-
$settings = wp_cache_get( CACHE_KEY );
83+
$settings = wp_cache_get( CACHE_KEY, CACHE_GROUP );
8384
if ( $settings ) {
8485
return $settings;
8586
}
@@ -93,7 +94,7 @@ function get_settings_values(): array {
9394
}
9495
}
9596

96-
wp_cache_set( CACHE_KEY, $settings );
97+
wp_cache_set( CACHE_KEY, $settings, CACHE_GROUP );
9798
return $settings;
9899
}
99100

@@ -125,7 +126,7 @@ function update_setting( string $section, string $field, $new_value ): bool {
125126

126127
$settings[ $section ][ $field ] = $new_value;
127128

128-
wp_cache_set( CACHE_KEY, $settings );
129+
wp_cache_set( CACHE_KEY, $settings, CACHE_GROUP );
129130
return update_self_option( are_settings_unified(), OPTION_NAME, $settings );
130131
}
131132

@@ -306,7 +307,7 @@ function process_settings_actions( array $input ): ?array {
306307
* @return array<string, array<string, mixed>> The validated settings.
307308
*/
308309
function sanitize_settings( array $input ): array {
309-
wp_cache_delete( CACHE_KEY );
310+
wp_cache_delete( CACHE_KEY, CACHE_GROUP );
310311
$result = process_settings_actions( $input );
311312

312313
if ( ! is_null( $result ) ) {

0 commit comments

Comments
 (0)