Ticket #64553: 64553-option-php.patch
| File 64553-option-php.patch, 12.1 KB (added by , 7 weeks ago) |
|---|
-
wp-includes/option.php
245 245 * 246 246 * The dynamic portion of the hook name, `$option`, refers to the option name. 247 247 * 248 * @since 1.5.0 As `option_{$setting}`.248 * @since 1.5.0 As 'option_' . $setting 249 249 * @since 3.0.0 250 250 * @since 4.4.0 The `$option` parameter was added. 251 251 * … … 1325 1325 * 1326 1326 * @since 6.6.0 1327 1327 * 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. 1333 1332 */ 1334 1333 $autoload = apply_filters( 'wp_default_autoload_value', null, $option, $value, $serialized_value ); 1335 1334 if ( is_bool( $autoload ) ) { … … 1634 1633 * 1635 1634 * @global wpdb $wpdb WordPress database abstraction object. 1636 1635 * 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). 1638 1640 */ 1639 function delete_expired_transients( $force_db = false ) {1641 function delete_expired_transients( $force_db = false, $name = false ) { 1640 1642 global $wpdb; 1641 1643 1642 1644 if ( ! $force_db && wp_using_ext_object_cache() ) { … … 1643 1645 return; 1644 1646 } 1645 1647 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 1646 1654 $wpdb->query( 1647 1655 $wpdb->prepare( 1648 1656 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b … … 1650 1658 AND a.option_name NOT LIKE %s 1651 1659 AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) 1652 1660 AND b.option_value < %d", 1653 $ wpdb->esc_like( '_transient_' ) . '%',1661 $transient_like, 1654 1662 $wpdb->esc_like( '_transient_timeout_' ) . '%', 1655 1663 time() 1656 1664 ) … … 1657 1665 ); 1658 1666 1659 1667 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 1660 1674 // Single site stores site transients in the options table. 1661 1675 $wpdb->query( 1662 1676 $wpdb->prepare( … … 1665 1679 AND a.option_name NOT LIKE %s 1666 1680 AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) 1667 1681 AND b.option_value < %d", 1668 $ wpdb->esc_like( '_site_transient_' ) . '%',1682 $site_transient_like, 1669 1683 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 1670 1684 time() 1671 1685 ) 1672 1686 ); 1673 1687 } 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 1674 1694 // Multisite stores site transients in the sitemeta table. 1675 1695 $wpdb->query( 1676 1696 $wpdb->prepare( … … 1679 1699 AND a.meta_key NOT LIKE %s 1680 1700 AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) 1681 1701 AND b.meta_value < %d", 1682 $ wpdb->esc_like( '_site_transient_' ) . '%',1702 $site_transient_like, 1683 1703 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 1684 1704 time() 1685 1705 ) … … 2021 2041 * Returning a value other than false from the filter will short-circuit retrieval 2022 2042 * and return that value instead. 2023 2043 * 2024 * @since 2.9.0 As `pre_site_option_{$key}`.2044 * @since 2.9.0 As 'pre_site_option_' . $key 2025 2045 * @since 3.0.0 2026 2046 * @since 4.4.0 The `$option` parameter was added. 2027 2047 * @since 4.7.0 The `$network_id` parameter was added. … … 2124 2144 * 2125 2145 * The dynamic portion of the hook name, `$option`, refers to the option name. 2126 2146 * 2127 * @since 2.9.0 As `site_option_{$key}`.2147 * @since 2.9.0 As 'site_option_' . $key 2128 2148 * @since 3.0.0 2129 2149 * @since 4.4.0 The `$option` parameter was added. 2130 2150 * @since 4.7.0 The `$network_id` parameter was added. … … 2173 2193 * 2174 2194 * The dynamic portion of the hook name, `$option`, refers to the option name. 2175 2195 * 2176 * @since 2.9.0 As `pre_add_site_option_{$key}`.2196 * @since 2.9.0 As 'pre_add_site_option_' . $key 2177 2197 * @since 3.0.0 2178 2198 * @since 4.4.0 The `$option` parameter was added. 2179 2199 * @since 4.7.0 The `$network_id` parameter was added. … … 2237 2257 * 2238 2258 * The dynamic portion of the hook name, `$option`, refers to the option name. 2239 2259 * 2240 * @since 2.9.0 As `add_site_option_{$key}`.2260 * @since 2.9.0 As "add_site_option_{$key}" 2241 2261 * @since 3.0.0 2242 2262 * @since 4.7.0 The `$network_id` parameter was added. 2243 2263 * … … 2343 2363 * 2344 2364 * The dynamic portion of the hook name, `$option`, refers to the option name. 2345 2365 * 2346 * @since 2.9.0 As `delete_site_option_{$key}`.2366 * @since 2.9.0 As "delete_site_option_{$key}" 2347 2367 * @since 3.0.0 2348 2368 * @since 4.7.0 The `$network_id` parameter was added. 2349 2369 *