From e512f0f44c152f413391e4ba6a5aad24d411af35 Mon Sep 17 00:00:00 2001 From: igorkrz Date: Wed, 24 May 2023 13:17:02 +0200 Subject: [PATCH] Change SearchExpression context from tokenized to exact --- lib/Core/Provider/Cloudinary/Resolver/SearchExpression.php | 2 +- .../Provider/Cloudinary/Resolver/SearchExpressionTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Core/Provider/Cloudinary/Resolver/SearchExpression.php b/lib/Core/Provider/Cloudinary/Resolver/SearchExpression.php index d2058597..77702cc6 100644 --- a/lib/Core/Provider/Cloudinary/Resolver/SearchExpression.php +++ b/lib/Core/Provider/Cloudinary/Resolver/SearchExpression.php @@ -291,7 +291,7 @@ static function (&$value, $key) { $value = is_array($value) ? $value : [$value]; $newContext = []; foreach ($context as $key => $values) { - $newContext[] = ('(context.' . $key . ':"' . implode('" OR context.' . $key . ':"', $values) . '")'); + $newContext[] = ('(context.' . $key . '="' . implode('" OR context.' . $key . '="', $values) . '")'); } return '(' . implode(' AND ', $newContext) . ')'; diff --git a/tests/lib/Core/Provider/Cloudinary/Resolver/SearchExpressionTest.php b/tests/lib/Core/Provider/Cloudinary/Resolver/SearchExpressionTest.php index 6f69928b..57afdea8 100644 --- a/tests/lib/Core/Provider/Cloudinary/Resolver/SearchExpressionTest.php +++ b/tests/lib/Core/Provider/Cloudinary/Resolver/SearchExpressionTest.php @@ -54,7 +54,7 @@ public static function dataProvider(): array folders: ['root/images/1', 'root/videos/2'], context: ['type' => ['product_image', 'category_image'], 'source' => 'user_upload'], ), - '(folder:"root/images/1" OR folder:"root/videos/2") AND ((context.type:"product_image" OR context.type:"category_image") AND (context.source:"user_upload"))', + '(folder:"root/images/1" OR folder:"root/videos/2") AND ((context.type="product_image" OR context.type="category_image") AND (context.source="user_upload"))', ], [ new Query(remoteIds: ['upload|image|root/test/picture1', 'upload|image|root/test/picture2', 'upload|image|root/test/picture3']), @@ -89,7 +89,7 @@ public static function dataProvider(): array . ' AND (((!format="aac") AND (!format="aiff") AND (!format="amr") AND (!format="flac") AND (!format="m4a")' . ' AND (!format="mp3") AND (!format="ogg") AND (!format="opus") AND (!format="wav") AND (!format="pdf")' . ' AND (!format="doc") AND (!format="docx") AND (!format="ppt") AND (!format="pptx") AND (!format="txt")))' - . ' AND ((context.source:"user_upload"))', + . ' AND ((context.source="user_upload"))', ], [ new Query(visibilities: ['public']), @@ -156,7 +156,7 @@ public static function dataProvider(): array . ' AND (tags:"tech" OR tags:"nature")' . ' AND (public_id:"root/test/picture1" OR public_id:"root/test/picture2" OR public_id:"root/test/picture3")' . ' AND (etag="hash1" OR etag="hash2")' - . ' AND ((context.original_filename:"picture_*") AND (context.type:"product_image" OR context.type:"category_image"))', + . ' AND ((context.original_filename="picture_*") AND (context.type="product_image" OR context.type="category_image"))', ], ]; }