Make WordPress Core


Ignore:
Timestamp:
10/26/2023 10:54:15 PM (14 months ago)
Author:
peterwilsoncc
Message:

Options, Meta APIs: Rename option cache priming functions.

Rename the option cache priming functions to more closely follow the naming convention used by other cache priming functions.

  • wp_load_options() becomes wp_prime_option_caches()
  • wp_load_options_by_group() becomes wp_prime_option_caches_by_group()

The unit test files and classes are renamed accordingly.

Unlike the existing cache priming functions, these functions were introduced with the intention of being public so use the wp_ prefix rather than the _ prefix used by the functions initially introduced as private functions but since made public.

Follow up to [56445],[56990].

Props flixos90, peterwilsoncc, joemcgill, SergeyBiryukov, desrosj.
Fixes #58962.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/wpPrimeOptionCachesByGroup.php

    r57012 r57013  
    11<?php
    22/**
    3  * Test wp_load_options_by_group().
     3 * Test wp_prime_option_caches_by_group().
    44 *
    55 * @group option
    66 *
    7  * @covers ::wp_load_options_by_group
     7 * @covers ::wp_prime_option_caches_by_group
    88 */
    9 class Tests_Option_PrimeOptionsByGroup extends WP_UnitTestCase {
     9class Tests_Option_WpPrimeOptionCachesByGroup extends WP_UnitTestCase {
    1010
    1111    /**
    12      * Tests that wp_load_options_by_group() only loads options in the specified group.
     12     * Tests that wp_prime_option_caches_by_group() only primes options in the specified group.
    1313     *
    1414     * @ticket 58962
    1515     */
    16     public function test_wp_load_options_by_group() {
     16    public function test_wp_prime_option_caches_by_group() {
    1717        global $new_allowed_options;
    1818
    19         // Create some options to load.
     19        // Create some options to prime.
    2020        $new_allowed_options = array(
    2121            'group1' => array(
     
    2828        );
    2929
    30         $options_to_load = array(
     30        $options_to_prime = array(
    3131            'option1',
    3232            'option2',
     
    3939         * check options are not in cache initially.
    4040         */
    41         foreach ( $options_to_load as $option ) {
     41        foreach ( $options_to_prime as $option ) {
    4242            update_option( $option, "value_$option", false );
    4343            wp_cache_delete( $option, 'options' );
     
    4545        }
    4646
    47         // Call the wp_load_options_by_group function to load the options.
    48         wp_load_options_by_group( 'group1' );
     47        // Call the wp_prime_option_caches_by_group function to prime the options.
     48        wp_prime_option_caches_by_group( 'group1' );
    4949
    5050        // Check that options are now in the cache.
    51         $this->assertSame( get_option( 'option1' ), wp_cache_get( 'option1', 'options' ), 'option1 was not loaded.' );
    52         $this->assertSame( get_option( 'option2' ), wp_cache_get( 'option2', 'options' ), 'option2 was not loaded.' );
     51        $this->assertSame( get_option( 'option1' ), wp_cache_get( 'option1', 'options' ), 'option1\'s cache was not primed.' );
     52        $this->assertSame( get_option( 'option2' ), wp_cache_get( 'option2', 'options' ), 'option2\'s cache was not primed.' );
    5353
    5454        // Make sure option3 is still not in cache.
     
    5757
    5858    /**
    59      * Tests wp_load_options_by_group() with a nonexistent option group.
     59     * Tests wp_prime_option_caches_by_group() with a nonexistent option group.
    6060     *
    6161     * @ticket 58962
    6262     */
    63     public function test_wp_load_options_by_group_with_nonexistent_group() {
     63    public function test_wp_prime_option_caches_by_group_with_nonexistent_group() {
    6464        // Make sure options are not in cache or database initially.
    6565        $this->assertFalse( wp_cache_get( 'option1', 'options' ), 'option1 was not deleted from the cache.' );
    6666        $this->assertFalse( wp_cache_get( 'option2', 'options' ), 'option2 was not deleted from the cache.' );
    6767
    68         // Call the wp_load_options_by_group function with a nonexistent group.
    69         wp_load_options_by_group( 'nonexistent_group' );
     68        // Call the wp_prime_option_caches_by_group function with a nonexistent group.
     69        wp_prime_option_caches_by_group( 'nonexistent_group' );
    7070
    7171        // Check that options are still not in the cache or database.
Note: See TracChangeset for help on using the changeset viewer.