Make WordPress Core


Ignore:
Timestamp:
08/28/2024 04:39:30 PM (20 months ago)
Author:
flixos90
Message:

Options, Meta APIs: Stop using 'yes' and 'no' for autoload parameter in favor of recommended boolean.

This changeset does not modify any behavior, it only updates the code to use the recommended type for the $autoload parameter as of WordPress 6.6. The old values 'yes' and 'no' are only maintained in certain tests that are explicitly about these backward compatibility values.

Props flixos90, joemcgill, mukesh27.
Fixes #61939.
See #61103, #61929.

File:
1 edited

Legend:

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

    r57920 r58945  
    1111    /**
    1212     * Tests that setting an option's autoload value to 'yes' works as expected.
     13     *
     14     * The values 'yes' and 'no' are only supported for backward compatibility.
    1315     *
    1416     * @ticket 58964
     
    3032    /**
    3133     * Tests that setting an option's autoload value to 'no' works as expected.
     34     *
     35     * The values 'yes' and 'no' are only supported for backward compatibility.
    3236     *
    3337     * @ticket 58964
     
    5761        $value  = 'value';
    5862
    59         add_option( $option, $value, '', 'yes' );
     63        add_option( $option, $value, '', true );
    6064
    61         $this->assertFalse( wp_set_option_autoload( $option, 'yes' ), 'Function did unexpectedly succeed' );
     65        $this->assertFalse( wp_set_option_autoload( $option, true ), 'Function did unexpectedly succeed' );
    6266        $this->assertSame( 'on', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ), 'Option autoload value unexpectedly updated in database' );
    6367    }
     
    7377        $option = 'test_option';
    7478
    75         $this->assertFalse( wp_set_option_autoload( $option, 'yes' ), 'Function did unexpectedly succeed' );
     79        $this->assertFalse( wp_set_option_autoload( $option, true ), 'Function did unexpectedly succeed' );
    7680        $this->assertNull( $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ), 'Missing option autoload value was set in database' );
    7781        $this->assertArrayNotHasKey( $option, wp_cache_get( 'alloptions', 'options' ), 'Missing option found in alloptions cache' );
Note: See TracChangeset for help on using the changeset viewer.