pantheon-systems / wp-redis

WordPress Object Cache using Redis.
https://wordpress.org/plugins/wp-redis/
GNU General Public License v2.0
225 stars 68 forks source link

Fix logic associated with `WP_REDIS_IGNORE_GLOBAL_GROUPS` #333

Closed danielbachhuber closed 2 years ago

danielbachhuber commented 2 years ago

The array hasn't been run through array_fill_keys() yet, so need to inspect the array values

danielbachhuber commented 2 years ago

@JanThiel FYI - your original logic was broken ^^

JanThiel commented 2 years ago

@danielbachhuber Strange ... I have this working with array_diff_keys on our servers.

        public function add_global_groups( $groups ) {
                $groups = (array) $groups;

                // Filter global groups
                $groups              = array_diff_key( $groups, WP_REDIS_IGNORE_GLOBAL_GROUPS );

                $groups              = array_fill_keys( $groups, true );
                $this->global_groups = array_merge( $this->global_groups, $groups );
        }
wp> print_r($GLOBALS['wp_object_cache']->global_groups)
Array
(
    [site-transient] => 1
    [site-options] => 1
    [blog-lookup] => 1
    [blog-details] => 1
    [site-details] => 1
    [rss] => 1
    [global-posts] => 1
    [blog-id-cache] => 1
    [networks] => 1
    [sites] => 1
    [blog_meta] => 1
)

But thanks for fixing and letting me know.

JanThiel commented 2 years ago

But you are absolutely right ... at this point, there are no key => value pairs. Very strange. Sorry for that ;-)

danielbachhuber commented 2 years ago

No worries 😄 Thanks again for the pull request!