Making WordPress.org

Changeset 10116


Ignore:
Timestamp:
08/05/2020 01:36:05 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Search: Load ElasticSearch on direct rest api requests, even though ?s= might be set.

This allows for ElasticSearch to load while debugging search when directly accessing the rest api.
This is only useful for debugging, as searches through api.wordpress.org do not set $_GET['s'].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r10114 r10116  
    560560
    561561                // Instantiate our copy of the Jetpack_Search class.
    562                 if ( class_exists( 'Jetpack' ) && \Jetpack::get_option( 'id' ) && ! class_exists( 'Jetpack_Search' )
    563                         && ! isset( $_GET['s'] ) ) { // Don't run the ES query if we're going to redirect to the pretty search URL
    564                                 require_once __DIR__ . '/libs/site-search/jetpack-search.php';
    565                                 \Jetpack_Search::instance();
     562                if (
     563                        class_exists( 'Jetpack' ) &&
     564                        \Jetpack::get_option( 'id' ) && // Don't load in Meta Environments
     565                        ! class_exists( 'Jetpack_Search' ) &&
     566                        (
     567                                // Don't run the ES query if we're going to redirect to the pretty search URL
     568                                ! isset( $_GET['s'] )
     569                        ||
     570                                // But load it for the query-plugins REST API endpoint, for simpler debugging
     571                                ( false !== strpos( $_SERVER['REQUEST_URI'], 'wp-json/plugins/v1/query-plugins' ) )
     572                        )
     573                ) {
     574                        require_once __DIR__ . '/libs/site-search/jetpack-search.php';
     575                        \Jetpack_Search::instance();
    566576                }
    567577        }
Note: See TracChangeset for help on using the changeset viewer.