Skip to content

Commit ba9b3e5

Browse files
committed
Deprecate method IndexInfo::isGeoHaystack()
MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in a future release
1 parent 118f084 commit ba9b3e5

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

docs/reference/method/MongoDBModelIndexInfo-isGeoHaystack.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ MongoDB\\Model\\IndexInfo::isGeoHaystack()
44

55
.. versionadded:: 1.4
66

7+
.. deprecated:: 1.16
8+
MongoDB 5.0 and later no longer supports geoHaystack indexes.
9+
710
.. default-domain:: mongodb
811

912
.. contents:: On this page
@@ -24,10 +27,6 @@ Definition
2427

2528
function isGeoHaystack(): boolean
2629

27-
.. note::
28-
29-
MongoDB 5.0 and later no longer supports geoHaystack indexes.
30-
3130
Return Values
3231
-------------
3332

src/Model/IndexInfo.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ public function is2dSphere()
125125
* Return whether or not this index is of type geoHaystack.
126126
*
127127
* @return boolean
128+
* @deprecated Since 1.16: MongoDB 5.0 removes support for geoHaystack indexes.
128129
*/
129130
public function isGeoHaystack()
130131
{
132+
trigger_error('MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in a future release', E_USER_DEPRECATED);
133+
131134
return array_search('geoHaystack', $this->getKey(), true) !== false;
132135
}
133136

tests/Model/IndexInfoFunctionalTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function testIsGeoHaystack(): void
6060
$index = $result->current();
6161

6262
$this->assertEquals($indexName, $index->getName());
63-
$this->assertTrue($index->isGeoHaystack());
63+
$this->assertDeprecated(function () use ($index): void {
64+
$this->assertTrue($index->isGeoHaystack());
65+
});
6466
$this->assertEquals(5, $index['bucketSize']);
6567
}
6668

tests/Model/IndexInfoTest.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public function testBasicIndex(): void
2222
$this->assertSame('x_1', $info->getName());
2323
$this->assertSame('foo.bar', $info->getNamespace());
2424
$this->assertFalse($info->is2dSphere());
25-
$this->assertFalse($info->isGeoHaystack());
25+
$this->assertDeprecated(function () use ($info): void {
26+
$this->assertFalse($info->isGeoHaystack());
27+
});
2628
$this->assertFalse($info->isSparse());
2729
$this->assertFalse($info->isText());
2830
$this->assertFalse($info->isTtl());
@@ -44,7 +46,9 @@ public function testSparseIndex(): void
4446
$this->assertSame('y_sparse', $info->getName());
4547
$this->assertSame('foo.bar', $info->getNamespace());
4648
$this->assertFalse($info->is2dSphere());
47-
$this->assertFalse($info->isGeoHaystack());
49+
$this->assertDeprecated(function () use ($info): void {
50+
$this->assertFalse($info->isGeoHaystack());
51+
});
4852
$this->assertTrue($info->isSparse());
4953
$this->assertFalse($info->isText());
5054
$this->assertFalse($info->isTtl());
@@ -66,7 +70,9 @@ public function testUniqueIndex(): void
6670
$this->assertSame('z_unique', $info->getName());
6771
$this->assertSame('foo.bar', $info->getNamespace());
6872
$this->assertFalse($info->is2dSphere());
69-
$this->assertFalse($info->isGeoHaystack());
73+
$this->assertDeprecated(function () use ($info): void {
74+
$this->assertFalse($info->isGeoHaystack());
75+
});
7076
$this->assertFalse($info->isSparse());
7177
$this->assertFalse($info->isText());
7278
$this->assertFalse($info->isTtl());
@@ -88,7 +94,9 @@ public function testTtlIndex(): void
8894
$this->assertSame('z_unique', $info->getName());
8995
$this->assertSame('foo.bar', $info->getNamespace());
9096
$this->assertFalse($info->is2dSphere());
91-
$this->assertFalse($info->isGeoHaystack());
97+
$this->assertDeprecated(function () use ($info): void {
98+
$this->assertFalse($info->isGeoHaystack());
99+
});
92100
$this->assertFalse($info->isSparse());
93101
$this->assertFalse($info->isText());
94102
$this->assertTrue($info->isTtl());
@@ -166,7 +174,9 @@ public function testIs2dSphere(): void
166174
$this->assertSame('pos_2dsphere', $info->getName());
167175
$this->assertSame('foo.bar', $info->getNamespace());
168176
$this->assertTrue($info->is2dSphere());
169-
$this->assertFalse($info->isGeoHaystack());
177+
$this->assertDeprecated(function () use ($info): void {
178+
$this->assertFalse($info->isGeoHaystack());
179+
});
170180
$this->assertFalse($info->isSparse());
171181
$this->assertFalse($info->isText());
172182
$this->assertFalse($info->isTtl());
@@ -187,7 +197,9 @@ public function testIsGeoHaystack(): void
187197
$this->assertSame('pos2_geoHaystack_x_1', $info->getName());
188198
$this->assertSame('foo.bar', $info->getNamespace());
189199
$this->assertFalse($info->is2dSphere());
190-
$this->assertTrue($info->isGeoHaystack());
200+
$this->assertDeprecated(function () use ($info): void {
201+
$this->assertTrue($info->isGeoHaystack());
202+
});
191203
$this->assertFalse($info->isSparse());
192204
$this->assertFalse($info->isText());
193205
$this->assertFalse($info->isTtl());
@@ -208,7 +220,9 @@ public function testIsText(): void
208220
$this->assertSame('title_text_description_text', $info->getName());
209221
$this->assertSame('foo.bar', $info->getNamespace());
210222
$this->assertFalse($info->is2dSphere());
211-
$this->assertFalse($info->isGeoHaystack());
223+
$this->assertDeprecated(function () use ($info): void {
224+
$this->assertFalse($info->isGeoHaystack());
225+
});
212226
$this->assertFalse($info->isSparse());
213227
$this->assertTrue($info->isText());
214228
$this->assertFalse($info->isTtl());

0 commit comments

Comments
 (0)