Ticket #43233: 43233.diff
| File 43233.diff, 11.4 KB (added by , 8 years ago) |
|---|
-
src/wp-includes/option.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
1652 1652 * 1653 1653 * @since 2.9.0 1654 1654 * 1655 * @see delete_network_transient 1656 * 1655 1657 * @param string $transient Transient name. Expected to not be SQL-escaped. 1658 * 1656 1659 * @return bool True if successful, false otherwise 1657 1660 */ 1658 1661 function delete_site_transient( $transient ) { 1662 return delete_network_transient( null, $transient ); 1663 } 1664 1665 /** 1666 * Get the value of a site transient. 1667 * 1668 * If the transient does not exist, does not have a value, or has expired, 1669 * then the return value will be false. 1670 * 1671 * @since 2.9.0 1672 * 1673 * @see get_network_transient() 1674 * 1675 * @param string $transient Transient name. Expected to not be SQL-escaped. 1676 * 1677 * @return mixed Value of transient. 1678 */ 1679 function get_site_transient( $transient ) { 1680 return get_network_transient( null, $transient ); 1681 } 1682 1683 /** 1684 * Set/update the value of a site transient. 1685 * 1686 * You do not need to serialize values, if the value needs to be serialize, then 1687 * it will be serialized before it is set. 1688 * 1689 * @since 2.9.0 1690 * 1691 * @see set_network_transient() 1692 * 1693 * @param string $transient Transient name. Expected to not be SQL-escaped. Must be 1694 * 167 characters or fewer in length. 1695 * @param mixed $value Transient value. Expected to not be SQL-escaped. 1696 * @param int $expiration Optional. Time until expiration in seconds. Default 0 (no expiration). 1697 * 1698 * @return bool False if value was not set and true if value was set. 1699 */ 1700 function set_site_transient( $transient, $value, $expiration = 0 ) { 1701 return set_network_transient( null, $value, $expiration = 0 ); 1702 } 1703 1704 /** 1705 * Delete a network transient. 1706 * 1707 * @since 5.0.0 1708 * 1709 * @param string $transient Transient name. Expected to not be SQL-escaped. 1710 * @return bool True if successful, false otherwise 1711 * @param int $network_id ID of the network. 1712 */ 1713 function delete_network_transient( $network_id, $transient ) { 1659 1714 1660 1715 /** 1661 1716 * Fires immediately before a specific site transient is deleted. … … 1663 1718 * The dynamic portion of the hook name, `$transient`, refers to the transient name. 1664 1719 * 1665 1720 * @since 3.0.0 1721 * @since 5.0.0 The `$network_id` parameter was added. 1666 1722 * 1667 1723 * @param string $transient Transient name. 1724 * @param int $network_id ID of the network. 1668 1725 */ 1669 do_action( "delete_site_transient_{$transient}", $transient );1726 do_action( "delete_site_transient_{$transient}", $transient, $network_id ); 1670 1727 1671 1728 if ( wp_using_ext_object_cache() ) { 1672 $result = wp_cache_delete( $transient, 'site-transient' ); 1729 $cache_key = "$network_id:$transient"; 1730 $result = wp_cache_delete( $cache_key, 'site-transient' ); 1673 1731 } else { 1674 1732 $option_timeout = '_site_transient_timeout_' . $transient; 1675 1733 $option = '_site_transient_' . $transient; 1676 $result = delete_ site_option($option );1734 $result = delete_network_option( $network_id, $option ); 1677 1735 if ( $result ) { 1678 delete_ site_option($option_timeout );1736 delete_network_option( $network_id, $option_timeout ); 1679 1737 } 1680 1738 } 1681 1739 if ( $result ) { … … 1686 1744 * @since 3.0.0 1687 1745 * 1688 1746 * @param string $transient Deleted transient name. 1747 * @param int $network_id ID of the network. 1689 1748 */ 1690 do_action( 'deleted_site_transient', $transient );1749 do_action( 'deleted_site_transient', $transient, $network_id ); 1691 1750 } 1692 1751 1693 1752 return $result; 1694 1753 } 1695 1754 1696 1755 /** 1697 * Get the value of a sitetransient.1756 * Get the value of a network transient. 1698 1757 * 1699 1758 * If the transient does not exist, does not have a value, or has expired, 1700 1759 * then the return value will be false. 1701 1760 * 1702 * @since 2.9.01761 * @since 5.0.0 1703 1762 * 1704 1763 * @see get_transient() 1705 * 1764 1765 * @param int $network_id ID of the network. 1706 1766 * @param string $transient Transient name. Expected to not be SQL-escaped. 1707 1767 * @return mixed Value of transient. 1708 1768 */ 1709 function get_ site_transient($transient ) {1769 function get_network_transient( $network_id, $transient ) { 1710 1770 1711 1771 /** 1712 * Filters the value of an existing sitetransient.1772 * Filters the value of an existing network transient. 1713 1773 * 1714 1774 * The dynamic portion of the hook name, `$transient`, refers to the transient name. 1715 1775 * … … 1718 1778 * 1719 1779 * @since 2.9.0 1720 1780 * @since 4.4.0 The `$transient` parameter was added. 1781 * @since 5.0.0 The `$network_id` parameter was added. 1721 1782 * 1722 1783 * @param mixed $pre_site_transient The default value to return if the site transient does not exist. 1723 1784 * Any value other than false will short-circuit the retrieval 1724 1785 * of the transient, and return the returned value. 1725 1786 * @param string $transient Transient name. 1787 * @param int $network_id ID of the network. 1726 1788 */ 1727 $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );1789 $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient, $network_id ); 1728 1790 1729 1791 if ( false !== $pre ) { 1730 1792 return $pre; 1731 1793 } 1732 1794 1733 1795 if ( wp_using_ext_object_cache() ) { 1734 $value = wp_cache_get( $transient, 'site-transient' ); 1796 $cache_key = "$network_id:$transient"; 1797 $value = wp_cache_get( $cache_key, 'site-transient' ); 1735 1798 } else { 1736 1799 // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. 1737 1800 $no_timeout = array( 'update_core', 'update_plugins', 'update_themes' ); 1738 1801 $transient_option = '_site_transient_' . $transient; 1739 1802 if ( ! in_array( $transient, $no_timeout ) ) { 1740 1803 $transient_timeout = '_site_transient_timeout_' . $transient; 1741 $timeout = get_ site_option($transient_timeout );1804 $timeout = get_network_option( $network_id, $transient_timeout ); 1742 1805 if ( false !== $timeout && $timeout < time() ) { 1743 delete_ site_option($transient_option );1744 delete_ site_option($transient_timeout );1806 delete_network_option( $network_id, $transient_option ); 1807 delete_network_option( $network_id, $transient_timeout ); 1745 1808 $value = false; 1746 1809 } 1747 1810 } 1748 1811 1749 1812 if ( ! isset( $value ) ) { 1750 $value = get_ site_option($transient_option );1813 $value = get_network_option( $network_id, $transient_option ); 1751 1814 } 1752 1815 } 1753 1816 … … 1758 1821 * 1759 1822 * @since 2.9.0 1760 1823 * @since 4.4.0 The `$transient` parameter was added. 1824 * @since 5.0.0 The `$network_id` parameter was added. 1761 1825 * 1762 1826 * @param mixed $value Value of site transient. 1763 1827 * @param string $transient Transient name. 1828 * @param int $network_id ID of the network. 1764 1829 */ 1765 return apply_filters( "site_transient_{$transient}", $value, $transient );1830 return apply_filters( "site_transient_{$transient}", $value, $transient, $network_id ); 1766 1831 } 1767 1832 1768 1833 /** 1769 * Set/update the value of a sitetransient.1834 * Set/update the value of a network transient. 1770 1835 * 1771 1836 * You do not need to serialize values, if the value needs to be serialize, then 1772 1837 * it will be serialized before it is set. 1773 1838 * 1774 * @since 2.9.01839 * @since 5.0.0 1775 1840 * 1776 1841 * @see set_transient() 1777 1842 * … … 1781 1846 * @param int $expiration Optional. Time until expiration in seconds. Default 0 (no expiration). 1782 1847 * @return bool False if value was not set and true if value was set. 1783 1848 */ 1784 function set_ site_transient($transient, $value, $expiration = 0 ) {1849 function set_network_transient( $network_id, $transient, $value, $expiration = 0 ) { 1785 1850 1786 1851 /** 1787 * Filters the value of a specific sitetransient before it is set.1852 * Filters the value of a specific network transient before it is set. 1788 1853 * 1789 1854 * The dynamic portion of the hook name, `$transient`, refers to the transient name. 1790 1855 * 1791 1856 * @since 3.0.0 1792 1857 * @since 4.4.0 The `$transient` parameter was added. 1858 * @since 5.0.0 The `$network_id` parameter was added. 1793 1859 * 1794 1860 * @param mixed $value New value of site transient. 1795 1861 * @param string $transient Transient name. 1862 * @param int $network_id ID of the network. 1796 1863 */ 1797 $value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );1864 $value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient, $network_id ); 1798 1865 1799 1866 $expiration = (int) $expiration; 1800 1867 1801 1868 /** 1802 * Filters the expiration for a sitetransient before its value is set.1869 * Filters the expiration for a network transient before its value is set. 1803 1870 * 1804 1871 * The dynamic portion of the hook name, `$transient`, refers to the transient name. 1805 1872 * 1806 1873 * @since 4.4.0 1874 * @since 5.0.0 The `$network_id` parameter was added. 1807 1875 * 1808 1876 * @param int $expiration Time until expiration in seconds. Use 0 for no expiration. 1809 1877 * @param mixed $value New value of site transient. 1810 1878 * @param string $transient Transient name. 1879 * @param int $network_id ID of the network. 1811 1880 */ 1812 $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );1881 $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient, $network_id ); 1813 1882 1814 1883 if ( wp_using_ext_object_cache() ) { 1815 $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); 1884 $cache_key = "$network_id:$transient"; 1885 $result = wp_cache_set( $cache_key, $value, 'site-transient', $expiration ); 1816 1886 } else { 1817 1887 $transient_timeout = '_site_transient_timeout_' . $transient; 1818 1888 $option = '_site_transient_' . $transient; 1819 if ( false === get_ site_option($option ) ) {1889 if ( false === get_network_option( $network_id, $option ) ) { 1820 1890 if ( $expiration ) { 1821 add_ site_option($transient_timeout, time() + $expiration );1891 add_network_option( $network_id, $transient_timeout, time() + $expiration ); 1822 1892 } 1823 $result = add_ site_option($option, $value );1893 $result = add_network_option( $network_id, $option, $value ); 1824 1894 } else { 1825 1895 if ( $expiration ) { 1826 update_ site_option($transient_timeout, time() + $expiration );1896 update_network_option( $network_id, $transient_timeout, time() + $expiration ); 1827 1897 } 1828 $result = update_ site_option($option, $value );1898 $result = update_network_option( $network_id, $option, $value ); 1829 1899 } 1830 1900 } 1831 1901 if ( $result ) { 1832 1902 1833 1903 /** 1834 * Fires after the value for a specific sitetransient has been set.1904 * Fires after the value for a specific network transient has been set. 1835 1905 * 1836 1906 * The dynamic portion of the hook name, `$transient`, refers to the transient name. 1837 1907 * 1838 1908 * @since 3.0.0 1839 1909 * @since 4.4.0 The `$transient` parameter was added 1910 * @since 5.0.0 The `$network_id` parameter was added. 1840 1911 * 1841 1912 * @param mixed $value Site transient value. 1842 1913 * @param int $expiration Time until expiration in seconds. 1843 1914 * @param string $transient Transient name. 1915 * @param int $network_id ID of the network. 1844 1916 */ 1845 do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );1917 do_action( "set_site_transient_{$transient}", $value, $expiration, $transient, $network_id ); 1846 1918 1847 1919 /** 1848 * Fires after the value for a sitetransient has been set.1920 * Fires after the value for a network transient has been set. 1849 1921 * 1850 1922 * @since 3.0.0 1923 * @since 5.0.0 The `$network_id` parameter was added. 1851 1924 * 1852 1925 * @param string $transient The name of the site transient. 1853 1926 * @param mixed $value Site transient value. 1854 1927 * @param int $expiration Time until expiration in seconds. 1928 * @param int $network_id ID of the network. 1855 1929 */ 1856 do_action( 'setted_site_transient', $transient, $value, $expiration );1930 do_action( 'setted_site_transient', $transient, $value, $expiration, $network_id ); 1857 1931 } 1858 1932 return $result; 1859 1933 }