-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-1057: Deprecate method IndexInfo::isGeoHaystack() #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -23,6 +23,9 @@ | |||||||
|
||||||||
use function array_key_exists; | ||||||||
use function array_search; | ||||||||
use function trigger_error; | ||||||||
|
||||||||
use const E_USER_DEPRECATED; | ||||||||
|
||||||||
/** | ||||||||
* Index information model class. | ||||||||
|
@@ -124,9 +127,12 @@ public function is2dSphere() | |||||||
* Return whether or not this index is of type geoHaystack. | ||||||||
* | ||||||||
* @return boolean | ||||||||
* @deprecated Since 1.16: MongoDB 5.0 removes support for geoHaystack indexes. | ||||||||
*/ | ||||||||
public function isGeoHaystack() | ||||||||
{ | ||||||||
trigger_error('MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in a future release', E_USER_DEPRECATED); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was initially going to point out the phpcs errors below and suggest running Thinking about this some more, I don't think we should actually trigger an error here. So long as the driver may be connected to a pre-5.0 server, it's possible for such an index to exist and there's no reason this method should interrupt the user (especially since it's just an "isser" and not something that would enable them to create such an index). In the other places where we do this, options are unsupported or deprecated in all of our supported server versions but still stuck in our public API. If PHPC (via the PHPLIB dependnecy) required a 5.0+ server we could certainly add this but I'm not convinced there's much value in doing so. Instead, I'd suggest a separate JIRA ticket with fixVersion 2.0 to just remind us to back and delete this method from the public API. And consider adding a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
mongo-php-library/src/Operation/CreateCollection.php Lines 240 to 242 in f75d3a8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense.
I propose leaving this PR open until we can discuss PHPLIB-1159 as a team. If we're in agreement that leaving There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided to keep the deprecation trigger. |
||||||||
|
||||||||
return array_search('geoHaystack', $this->getKey(), true) !== false; | ||||||||
} | ||||||||
|
||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,9 @@ public function testIsGeoHaystack(): void | |
$index = $result->current(); | ||
|
||
$this->assertEquals($indexName, $index->getName()); | ||
$this->assertTrue($index->isGeoHaystack()); | ||
$this->assertDeprecated(function () use ($index): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot this method existed. It dates back to 4b4a7d9#diff-abf1fa77a19f720052b75bc802df0260157b9064d8c3c12a80794f01e9acc065R136. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was happy to find it, otherwise I the tests failed. |
||
$this->assertTrue($index->isGeoHaystack()); | ||
}); | ||
$this->assertEquals(5, $index['bucketSize']); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc was updated in #1085 (comment) to mention the feature deprecation. I moved this note to a deprecation block.