WordPress.org

Make WordPress Core

Ticket #43160: a43160.diff

File a43160.diff, 3.2 KB (added by kitchin, 3 years ago)

Here it is as a patch against trunk. Not tested.

  • wp-includes/option.php

     
    17661766}
    17671767
    17681768/**
     1769 * Set/update the value of a site transient without calling the sometimes expensive hooks.
     1770 *
     1771 * This is particularly for the special case of wp_update_plugins() where set_site_transient() was called twice
     1772 * and the first time was only for setting up the last_checked update_plugins option.
     1773 *
     1774 * @since 4.9.3
     1775 *
     1776 * @see wp_update_plugins()
     1777 *
     1778 * @param string $transient  Transient name. Expected to not be SQL-escaped. Must be
     1779 *                           167 characters or fewer in length.
     1780 * @param mixed  $value      Transient value. Expected to not be SQL-escaped.
     1781 * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
     1782 * @return bool False if value was not set and true if value was set.
     1783*/
     1784function set_site_transient_nohook( $transient, $value, $expiration = 0 ) {
     1785
     1786        $expiration = (int) $expiration;
     1787
     1788        if ( wp_using_ext_object_cache() ) {
     1789                $result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
     1790        } else {
     1791                $transient_timeout = '_site_transient_timeout_' . $transient;
     1792                $option = '_site_transient_' . $transient;
     1793                if ( false === get_site_option( $option ) ) {
     1794                        if ( $expiration )
     1795                                add_site_option( $transient_timeout, time() + $expiration );
     1796                        $result = add_site_option( $option, $value );
     1797                } else {
     1798                        if ( $expiration )
     1799                                update_site_option( $transient_timeout, time() + $expiration );
     1800                        $result = update_site_option( $option, $value );
     1801                }
     1802        }
     1803        return $result;
     1804}
     1805
     1806/**
    17691807 * Set/update the value of a site transient.
    17701808 *
    17711809 * You do not need to serialize values, if the value needs to be serialize, then
     
    18111849         */
    18121850        $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
    18131851
    1814         if ( wp_using_ext_object_cache() ) {
    1815                 $result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
    1816         } else {
    1817                 $transient_timeout = '_site_transient_timeout_' . $transient;
    1818                 $option            = '_site_transient_' . $transient;
    1819                 if ( false === get_site_option( $option ) ) {
    1820                         if ( $expiration ) {
    1821                                 add_site_option( $transient_timeout, time() + $expiration );
    1822                         }
    1823                         $result = add_site_option( $option, $value );
    1824                 } else {
    1825                         if ( $expiration ) {
    1826                                 update_site_option( $transient_timeout, time() + $expiration );
    1827                         }
    1828                         $result = update_site_option( $option, $value );
    1829                 }
    1830         }
     1852        $result = set_site_transient_nohook( $transient, $value, $expiration );
     1853
    18311854        if ( $result ) {
    18321855
    18331856                /**
  • wp-includes/update.php

     
    6767
    6868        // Update last_checked for current to prevent multiple blocking requests if request hangs
    6969        $current->last_checked = time();
    70         set_site_transient( 'update_core', $current );
     70        set_site_transient_nohook( 'update_plugins', $current );
    7171
    7272        if ( method_exists( $wpdb, 'db_version' ) ) {
    7373                $mysql_version = preg_replace( '/[^0-9.].*/', '', $wpdb->db_version() );