Make WordPress Core

Ticket #64553: 64553-option-php.patch

File 64553-option-php.patch, 12.1 KB (added by solankisoftware, 7 weeks ago)
  • wp-includes/option.php

     
    245245         *
    246246         * The dynamic portion of the hook name, `$option`, refers to the option name.
    247247         *
    248          * @since 1.5.0 As `option_{$setting}`.
     248         * @since 1.5.0 As 'option_' . $setting
    249249         * @since 3.0.0
    250250         * @since 4.4.0 The `$option` parameter was added.
    251251         *
     
    13251325         *
    13261326         * @since 6.6.0
    13271327         *
    1328          * @param bool|null $autoload         The default autoload value to set. Returning true will be set as 'auto-on' in the
    1329          *                                    database, false will be set as 'auto-off', and null will be set as 'auto'.
    1330          * @param string    $option           The passed option name.
    1331          * @param mixed     $value            The passed option value to be saved.
    1332          * @param mixed     $serialized_value The passed option value to be saved, in serialized form.
     1328         * @param bool|null $autoload The default autoload value to set. Returning true will be set as 'auto-on' in the
     1329         *                            database, false will be set as 'auto-off', and null will be set as 'auto'.
     1330         * @param string    $option   The passed option name.
     1331         * @param mixed     $value    The passed option value to be saved.
    13331332         */
    13341333        $autoload = apply_filters( 'wp_default_autoload_value', null, $option, $value, $serialized_value );
    13351334        if ( is_bool( $autoload ) ) {
     
    16341633 *
    16351634 * @global wpdb $wpdb WordPress database abstraction object.
    16361635 *
    1637  * @param bool $force_db Optional. Force cleanup to run against the database even when an external object cache is used.
     1636 * @param bool        $force_db Optional. Force cleanup to run against the database even when an external object cache is used.
     1637 *                               Default false.
     1638 * @param string|bool $name     Optional. Transient name or prefix to delete. If provided, only expired transients
     1639 *                               matching this name or prefix will be deleted. Default false (delete all expired transients).
    16381640 */
    1639 function delete_expired_transients( $force_db = false ) {
     1641function delete_expired_transients( $force_db = false, $name = false ) {
    16401642        global $wpdb;
    16411643
    16421644        if ( ! $force_db && wp_using_ext_object_cache() ) {
     
    16431645                return;
    16441646        }
    16451647
     1648        // Build the LIKE pattern for regular transients.
     1649        $transient_like = $wpdb->esc_like( '_transient_' ) . '%';
     1650        if ( $name ) {
     1651                $transient_like = $wpdb->esc_like( '_transient_' . $name ) . '%';
     1652        }
     1653
    16461654        $wpdb->query(
    16471655                $wpdb->prepare(
    16481656                        "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b
     
    16501658                        AND a.option_name NOT LIKE %s
    16511659                        AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
    16521660                        AND b.option_value < %d",
    1653                         $wpdb->esc_like( '_transient_' ) . '%',
     1661                        $transient_like,
    16541662                        $wpdb->esc_like( '_transient_timeout_' ) . '%',
    16551663                        time()
    16561664                )
     
    16571665        );
    16581666
    16591667        if ( ! is_multisite() ) {
     1668                // Build the LIKE pattern for site transients.
     1669                $site_transient_like = $wpdb->esc_like( '_site_transient_' ) . '%';
     1670                if ( $name ) {
     1671                        $site_transient_like = $wpdb->esc_like( '_site_transient_' . $name ) . '%';
     1672                }
     1673
    16601674                // Single site stores site transients in the options table.
    16611675                $wpdb->query(
    16621676                        $wpdb->prepare(
     
    16651679                                AND a.option_name NOT LIKE %s
    16661680                                AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
    16671681                                AND b.option_value < %d",
    1668                                 $wpdb->esc_like( '_site_transient_' ) . '%',
     1682                                $site_transient_like,
    16691683                                $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
    16701684                                time()
    16711685                        )
    16721686                );
    16731687        } elseif ( is_main_site() && is_main_network() ) {
     1688                // Build the LIKE pattern for site transients in multisite.
     1689                $site_transient_like = $wpdb->esc_like( '_site_transient_' ) . '%';
     1690                if ( $name ) {
     1691                        $site_transient_like = $wpdb->esc_like( '_site_transient_' . $name ) . '%';
     1692                }
     1693
    16741694                // Multisite stores site transients in the sitemeta table.
    16751695                $wpdb->query(
    16761696                        $wpdb->prepare(
     
    16791699                                AND a.meta_key NOT LIKE %s
    16801700                                AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
    16811701                                AND b.meta_value < %d",
    1682                                 $wpdb->esc_like( '_site_transient_' ) . '%',
     1702                                $site_transient_like,
    16831703                                $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
    16841704                                time()
    16851705                        )
     
    20212041         * Returning a value other than false from the filter will short-circuit retrieval
    20222042         * and return that value instead.
    20232043         *
    2024          * @since 2.9.0 As `pre_site_option_{$key}`.
     2044         * @since 2.9.0 As 'pre_site_option_' . $key
    20252045         * @since 3.0.0
    20262046         * @since 4.4.0 The `$option` parameter was added.
    20272047         * @since 4.7.0 The `$network_id` parameter was added.
     
    21242144         *
    21252145         * The dynamic portion of the hook name, `$option`, refers to the option name.
    21262146         *
    2127          * @since 2.9.0 As `site_option_{$key}`.
     2147         * @since 2.9.0 As 'site_option_' . $key
    21282148         * @since 3.0.0
    21292149         * @since 4.4.0 The `$option` parameter was added.
    21302150         * @since 4.7.0 The `$network_id` parameter was added.
     
    21732193         *
    21742194         * The dynamic portion of the hook name, `$option`, refers to the option name.
    21752195         *
    2176          * @since 2.9.0 As `pre_add_site_option_{$key}`.
     2196         * @since 2.9.0 As 'pre_add_site_option_' . $key
    21772197         * @since 3.0.0
    21782198         * @since 4.4.0 The `$option` parameter was added.
    21792199         * @since 4.7.0 The `$network_id` parameter was added.
     
    22372257                 *
    22382258                 * The dynamic portion of the hook name, `$option`, refers to the option name.
    22392259                 *
    2240                  * @since 2.9.0 As `add_site_option_{$key}`.
     2260                 * @since 2.9.0 As "add_site_option_{$key}"
    22412261                 * @since 3.0.0
    22422262                 * @since 4.7.0 The `$network_id` parameter was added.
    22432263                 *
     
    23432363                 *
    23442364                 * The dynamic portion of the hook name, `$option`, refers to the option name.
    23452365                 *
    2346                  * @since 2.9.0 As `delete_site_option_{$key}`.
     2366                 * @since 2.9.0 As "delete_site_option_{$key}"
    23472367                 * @since 3.0.0
    23482368                 * @since 4.7.0 The `$network_id` parameter was added.
    23492369                 *