WordPress.org

Make WordPress Core

Ticket #37958: 37958.patch

File 37958.patch, 4.9 KB (added by tfrommen, 3 years ago)
  • src/wp-includes/class-wp-xmlrpc-server.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    626626                        $primary_blog_id = (int) $active_blog->blog_id;
    627627                }
    628628
     629                $site_state = get_site_state();
     630
    629631                foreach ( $blogs as $blog ) {
    630632                        // Don't include blogs that aren't hosted at this site.
    631633                        if ( $blog->site_id != get_current_network_id() )
     
    646648                                'blogName'  => get_option( 'blogname' ),
    647649                                'xmlrpc'    => site_url( 'xmlrpc.php', 'rpc' ),
    648650                        );
    649 
    650                         restore_current_blog();
    651651                }
     652
     653                restore_site_state( $site_state );
    652654
    653655                return $struct;
    654656        }
  • src/wp-includes/class-wp-site-state.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
     1<?php
     2/**
     3 * Site API: WP_Site_State class
     4 *
     5 * @package WordPress
     6 * @subpackage Multisite
     7 * @since 4.8.0
     8 */
     9
     10/**
     11 * Core class used for storing and restoring site states.
     12 *
     13 * @since 4.8.0
     14 */
     15class WP_Site_State {
     16
     17        /**
     18         * @var int
     19         */
     20        private $site_id;
     21
     22        /**
     23         * @var array
     24         */
     25        private $stack;
     26
     27        /**
     28         * Constructor. Sets up the properties.
     29         *
     30         * @since 4.8.0
     31         *
     32         * @global array $_wp_switched_stack
     33         */
     34        public function __construct() {
     35                $this->site_id = get_current_blog_id();
     36                $this->stack = $GLOBALS['_wp_switched_stack'];
     37        }
     38
     39        /**
     40         * Restores the stored site state.
     41         *
     42         * @since 4.8.0
     43         *
     44         * @global array $_wp_switched_stack
     45         * @global bool $switched
     46         *
     47         * @return int The current site ID.
     48         */
     49        public function restore() {
     50                switch_to_blog( $this->site_id );
     51                $GLOBALS['_wp_switched_stack'] = $this->stack;
     52                $GLOBALS['switched'] = ! empty( $this->stack );
     53
     54                return get_current_blog_id();
     55        }
     56}
  • src/wp-admin/includes/ms.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    218218        $blogs = get_blogs_of_user( $id );
    219219
    220220        if ( ! empty( $blogs ) ) {
     221                $site_state = get_site_state();
     222
    221223                foreach ( $blogs as $blog ) {
    222224                        switch_to_blog( $blog->userblog_id );
    223225                        remove_user_from_blog( $id, $blog->userblog_id );
     
    234236                                foreach ( $link_ids as $link_id )
    235237                                        wp_delete_link( $link_id );
    236238                        }
    237 
    238                         restore_current_blog();
    239239                }
     240
     241                restore_site_state( $site_state );
    240242        }
    241243
    242244        $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
  • src/wp-includes/ms-load.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    556556
    557557        return $network;
    558558}
     559
     560/**
     561 * Returns a new object holding the current site state.
     562 *
     563 * @since 4.8.0
     564 *
     565 * @return WP_Site_State A new site state object.
     566 */
     567function get_site_state() {
     568        return new WP_Site_State();
     569}
     570
     571/**
     572 * Restores the given site state.
     573 *
     574 * @since 4.8.0
     575 *
     576 * @param WP_Site_State $site_state The object holding the site state to be restored.
     577 *
     578 * @return int The current site ID.
     579 */
     580function restore_site_state( WP_Site_State $site_state ) {
     581        return $site_state->restore();
     582}
  • src/wp-includes/admin-bar.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    490490                ),
    491491        ) );
    492492
     493        $site_state = get_site_state();
     494
    493495        foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    494496                switch_to_blog( $blog->userblog_id );
    495497
     
    541543                        'title'  => __( 'Visit Site' ),
    542544                        'href'   => home_url( '/' ),
    543545                ) );
    544 
    545                 restore_current_blog();
    546546        }
     547
     548        restore_site_state( $site_state );
    547549}
    548550
    549551/**
  • src/wp-includes/ms-settings.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    2828/** WP_Site class */
    2929require_once( ABSPATH . WPINC . '/class-wp-site.php' );
    3030
     31/** WP_Site_State class */
     32require_once( ABSPATH . WPINC . '/class-wp-site-state.php' );
     33
    3134/** Multisite loader */
    3235require_once( ABSPATH . WPINC . '/ms-load.php' );
    3336