Changeset 58182
- Timestamp:
- 05/21/2024 09:36:43 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r58134 r58182 644 644 645 645 /** 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 646 775 * Loads and primes caches of certain often requested network options if is_multisite(). 647 776 * 648 777 * @since 3.0.0 649 778 * @since 6.3.0 Also prime caches for network options when persistent object cache is enabled. 650 * 651 * @global wpdb $wpdb WordPress database abstraction object. 779 * @since 6.6.0 Uses wp_prime_network_option_caches(). 652 780 * 653 781 * @param int $network_id Optional. Network ID of network for which to prime network options cache. Defaults to current network. 654 782 */ 655 783 function wp_load_core_site_options( $network_id = null ) { 656 global $wpdb;657 658 784 if ( ! is_multisite() || wp_installing() ) { 659 785 return; 660 786 } 661 662 if ( empty( $network_id ) ) { 663 $network_id = get_current_network_id(); 664 } 665 666 $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 667 668 if ( wp_using_ext_object_cache() ) { 669 $cache_keys = array(); 670 foreach ( $core_options as $option ) { 671 $cache_keys[] = "{$network_id}:{$option}"; 672 } 673 wp_cache_get_multiple( $cache_keys, 'site-options' ); 674 675 return; 676 } 677 678 $core_options_in = "'" . implode( "', '", $core_options ) . "'"; 679 $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) ); 680 681 $data = array(); 682 foreach ( $options as $option ) { 683 $key = $option->meta_key; 684 $cache_key = "{$network_id}:$key"; 685 $option->meta_value = maybe_unserialize( $option->meta_value ); 686 687 $data[ $cache_key ] = $option->meta_value; 688 } 689 wp_cache_set_multiple( $data, 'site-options' ); 787 $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting', 'WPLANG' ); 788 789 wp_prime_network_option_caches( $network_id, $core_options ); 690 790 } 691 791 … … 2416 2516 if ( ! in_array( $transient, $no_timeout, true ) ) { 2417 2517 $transient_timeout = '_site_transient_timeout_' . $transient; 2418 $timeout = get_site_option( $transient_timeout ); 2518 wp_prime_site_option_caches( array( $transient_option, $transient_timeout ) ); 2519 2520 $timeout = get_site_option( $transient_timeout ); 2419 2521 if ( false !== $timeout && $timeout < time() ) { 2420 2522 delete_site_option( $transient_option ); … … 2494 2596 $transient_timeout = '_site_transient_timeout_' . $transient; 2495 2597 $option = '_site_transient_' . $transient; 2598 2496 2599 2497 2600 if ( false === get_site_option( $option ) ) {
Note: See TracChangeset
for help on using the changeset viewer.