Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/06/2014 06:58:17 PM (12 years ago)
Author:
boonebgorges
Message:

Store directory_pages data in the persistent cache.

This information is needed during every bootstrap, yet rarely changes, so there
should be significant performance benefit from caching it.

Invalidation takes place when one of the pages is updated, or when the bp-pages
option is changed.

Note that this change will likely be moot after migrating to the WP rewrite
API. See #4954.

See #5362

Props Denis-de-Bernardy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/core/functions.php

    r7426 r7809  
    256256        }
    257257
     258        /**
     259         * @group bp_core_get_directory_pages
     260         */
     261        public function test_bp_core_get_directory_pages_after_page_edit() {
     262                // Set the cache
     263                $pages = bp_core_get_directory_pages();
     264
     265                // Update one of the posts
     266                switch_to_blog( bp_get_root_blog_id() );
     267
     268                // grab the first one
     269                foreach ( $pages as $page ) {
     270                        $p = $page;
     271                        break;
     272                }
     273
     274                $post = get_post( $p->id );
     275                $post->post_title .= ' Foo';
     276                wp_update_post( $post );
     277
     278                restore_current_blog();
     279
     280                $this->assertFalse( wp_cache_get( 'directory_pages', 'bp' ) );
     281        }
     282
     283        /**
     284         * @group bp_core_get_directory_pages
     285         */
     286        public function test_bp_core_get_directory_pages_pages_settings_update() {
     287                // Set the cache
     288                $pages = bp_core_get_directory_pages();
     289
     290                // Mess with it but put it back
     291                $v = bp_get_option( 'bp-pages' );
     292                bp_update_option( 'bp-pages', 'foo' );
     293
     294                $this->assertFalse( wp_cache_get( 'directory_pages', 'bp' ) );
     295
     296                bp_update_option( 'bp-pages', $v );
     297        }
     298
    258299}
Note: See TracChangeset for help on using the changeset viewer.