From 226699ec86ea37976499a80bd4c2b774d55a3a8c Mon Sep 17 00:00:00 2001 From: Glynn Quelch Date: Mon, 23 Jun 2025 12:34:16 +0100 Subject: [PATCH] Do not cast the term to regex if no wildcards to avoid the issues a term with no * is treated as a plan string match --- mu-plugins/osi-api/osi-api.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mu-plugins/osi-api/osi-api.php b/mu-plugins/osi-api/osi-api.php index 7ee0edd..08d2241 100644 --- a/mu-plugins/osi-api/osi-api.php +++ b/mu-plugins/osi-api/osi-api.php @@ -136,13 +136,10 @@ public function get_licenses( WP_REST_Request $data ) { $args['post_title_like'] = sanitize_text_field( $searched_slug ); // Use the post name (slug) to filter by ID } elseif ( ! empty( $spdx ) ) { - // Cast the term to a regex pattern - $regex = $this->cast_wildcard_to_regex( $spdx ); - // If we have no wildcards, look for a direct match $args['meta_query'][] = array( 'key' => 'spdx_identifier_display_text', - 'value' => $regex, + 'value' => str_contains( $spdx, '*' ) ? $this->cast_wildcard_to_regex( $spdx ) : sanitize_text_field( $spdx ), 'compare' => str_contains( $spdx, '*' ) ? 'REGEXP' : '==', ); } elseif ( ! empty( $keyword ) ) {