From bdde4d9a7e3820fb060c7d12972beb79a3f7d8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 9 Sep 2025 09:42:52 +0200 Subject: [PATCH] Deprecate Stage::search() because the $search stage must be the first of the pipeline --- lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php index 3d90d55924..8343bcb3e4 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php @@ -368,10 +368,14 @@ public function sample(int $size): Stage\Sample * The $search stage performs a full-text search on the specified field or * fields which must be covered by an Atlas Search index. * + * @deprecated Since doctrine/mongodb-odm 2.13. This $search stage must be the first of the pipeline, use Builder::search() instead. + * * @see https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#mongodb-pipeline-pipe.-search */ public function search(): Stage\Search { + trigger_deprecation('doctrine/mongodb-odm', '2.13', 'Using "%s" is deprecated because the $search stage must be the first of the pipeline, use "%s::search()" instead.', __METHOD__, Builder::class); + return $this->builder->search(); }