Make WordPress Core

Ticket #35791: 35791c.1.patch

File 35791c.1.patch, 3.7 KB (added by spacedmonkey, 9 years ago)
  • wp-includes/date.php

     
    491491                $valid_columns = array(
    492492                        'post_date', 'post_date_gmt', 'post_modified',
    493493                        'post_modified_gmt', 'comment_date', 'comment_date_gmt',
    494                         'user_registered',
     494                        'user_registered', 'registered', 'last_updated',
    495495                );
    496496
    497497                // Attempt to detect a table prefix.
     
    525525                                $wpdb->users => array(
    526526                                        'user_registered',
    527527                                ),
     528                                $wpdb->blogs => array(
     529                                        'registered',
     530                                        'last_updated',
     531                                ),
    528532                        );
    529533
    530534                        // If it's a known column name, add the appropriate table prefix.
  • wp-includes/ms-blogs.php

     
    468468}
    469469
    470470/**
     471 * Retrieves site data given a site ID or site object.
     472 *
     473 * If an object is passed then the site data will be cached and then returned
     474 * after being passed through a filter. If the site is empty, then the global
     475 * site variable will be used, if it is set.
     476 *
     477 * @since 4.6.0
     478 *
     479 * @global WP_Site $site
     480 *
     481 * @param WP_Site|string|int $site Site to retrieve.
     482 * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
     483 *
     484 * @return WP_Site|array|null Depends on $output value.
     485 */
     486function get_site( &$site = null, $output = OBJECT ) {
     487        global $current_blog;
     488        if ( empty( $site ) && isset( $current_blog ) ) {
     489                $site = $current_blog;
     490        }
     491
     492        if ( $site instanceof WP_Site ) {
     493                $_site = $site;
     494        } elseif ( is_object( $site ) ) {
     495                $_site = new WP_Site( $site );
     496        } else {
     497                $_site = WP_Site::get_instance( $site );
     498        }
     499
     500        if ( ! $_site ) {
     501                return null;
     502        }
     503
     504        /**
     505         * Fires after a site is retrieved.
     506         *
     507         * @since 4.6.0
     508         *
     509         * @param mixed $_site Site data.
     510         */
     511        $_site = apply_filters( 'get_site', $_site );
     512
     513        if ( $output == OBJECT ) {
     514                return $_site;
     515        } elseif ( $output == ARRAY_A ) {
     516                return $_site->to_array();
     517        } elseif ( $output == ARRAY_N ) {
     518                return array_values( $_site->to_array() );
     519        }
     520
     521        return $_site;
     522}
     523
     524/**
     525 * Adds any sites from the given ids to the cache that do not already exist in cache
     526 *
     527 * @since 4.6.0
     528 * @access private
     529 *
     530 * @see update_site_cache()
     531 *
     532 * @global wpdb $wpdb WordPress database abstraction object.
     533 *
     534 * @param array $ids ID list.
     535 */
     536function _prime_site_caches( $ids ) {
     537        global $wpdb;
     538
     539        $non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
     540        if ( ! empty( $non_cached_ids ) ) {
     541                $fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", join( ",", $non_cached_ids ) ) );
     542
     543                update_site_cache( $fresh_sites );
     544        }
     545}
     546
     547/**
     548 * Updates sites in cache.
     549 *
     550 * @since 4.6.0
     551 *
     552 * @param array $sites Array of site objects, passed by reference.
     553 */
     554function update_site_cache( &$sites ) {
     555        if ( ! $sites ) {
     556                return;
     557        }
     558
     559        foreach ( $sites as $site ) {
     560                wp_cache_add( $site->blog_id, $site, 'sites' );
     561                wp_cache_add( $site->blog_id . 'short', $site, 'blog-details' );
     562        }
     563}
     564
     565/**
    471566 * Retrieve option value for a given blog id based on name of option.
    472567 *
    473568 * If the option does not exist or does not have a value, then the return value
  • wp-settings.php

     
    9999
    100100// Initialize multisite if enabled.
    101101if ( is_multisite() ) {
     102        require( ABSPATH . WPINC . '/class-wp-site-query.php' );
    102103        require( ABSPATH . WPINC . '/ms-blogs.php' );
    103104        require( ABSPATH . WPINC . '/ms-settings.php' );
    104105} elseif ( ! defined( 'MULTISITE' ) ) {