Commit 1da67e31b5 for wordpress.org

commit 1da67e31b5fde83104afa80a5a1fd60895b86605
Author: Felix Arntz <felix-arntz@leaves-and-love.net>
Date:   Tue Sep 17 21:58:14 2024 +0000

    REST API: Support exact search in the REST API posts endpoint.

    This changeset adds support for a new `search_semantics` enum query parameter that can be passed alongside the `search` string parameter. At this point, it only supports "exact" as possible value, but an enum is used for forward compatibility with potential enhancements like "sentence" search support. If `search_semantics=exact` is passed, it will look for an exact match rather than do a full text search, which for some use-cases is more appropriate and more performant.

    Props mehulkaklotar, timothyblynjacobs, jimmyh61, ironprogrammer, johnregan3, mukesh27, costdev.
    Fixes #56350.

    Built from https://develop.svn.wordpress.org/trunk@59034


    git-svn-id: http://core.svn.wordpress.org/trunk@58430 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index d6afdef470..11bc499fc6 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
@@ -337,6 +337,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
 			}
 		}

+		if (
+			isset( $registered['search_semantics'], $request['search_semantics'] )
+			&& 'exact' === $request['search_semantics']
+		) {
+			$args['exact'] = true;
+		}
+
 		$args = $this->prepare_tax_query( $args, $request );

 		// Force the post_type argument, since it's not a user input variable.
@@ -2886,6 +2893,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
 			);
 		}

+		$query_params['search_semantics'] = array(
+			'description' => __( 'How to interpret the search input.' ),
+			'type'        => 'string',
+			'enum'        => array( 'exact' ),
+		);
+
 		$query_params['offset'] = array(
 			'description' => __( 'Offset the result set by a specific number of items.' ),
 			'type'        => 'integer',
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 5a02630db2..b251507a86 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '6.7-alpha-59033';
+$wp_version = '6.7-alpha-59034';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.