-
Notifications
You must be signed in to change notification settings - Fork 974
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
Fix pre 7.2 endpoint class name with aliases + reapply fix #947 #968
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
adba49c
Fix pre 7.2 endpoint class name with aliases + reapply fix #947
ezimuel 441dcdc
Converted the class alias into strings
ezimuel 0c17769
Fixed alias issue + code generation with BC break fixes
ezimuel e11c6b9
Added the Cluster\Nodes\Info and Stats classes for BC support
ezimuel ec07a44
Added the missing Cluster\Nodes BC classes
ezimuel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* File required since elasticsearch-php 7.4.1 for aliasing | ||
* to the previous endpoint class names. | ||
* | ||
* @see https://github.com/elastic/elasticsearch-php/issues/967 | ||
* | ||
* NOTE: This file will be removed with elasticsearch-php 8.0.0 | ||
*/ | ||
|
||
class_alias('\Elasticsearch\Endpoints\Cat\Nodeattrs', '\Elasticsearch\Endpoints\Cat\NodeAttrs'); | ||
class_alias('\Elasticsearch\Endpoints\Cluster\GetSettings', '\Elasticsearch\Endpoints\Cluster\Settings\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Cluster\PutSettings', '\Elasticsearch\Endpoints\Cluster\Settings\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\DeleteAlias', '\Elasticsearch\Endpoints\Indices\Alias\Delete'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\ExistsAlias', '\Elasticsearch\Endpoints\Indices\Alias\Exists'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetAlias', '\Elasticsearch\Endpoints\Indices\Alias\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\PutAlias', '\Elasticsearch\Endpoints\Indices\Alias\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\UpdateAliases', '\Elasticsearch\Endpoints\Indices\Aliases\Update'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\ClearCache', '\Elasticsearch\Endpoints\Indices\Cache\Clear'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\Forcemerge', '\Elasticsearch\Endpoints\Indices\ForceMerge'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetMapping', '\Elasticsearch\Endpoints\Indices\Mapping\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetFieldMapping', '\Elasticsearch\Endpoints\Indices\Mapping\GetField'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\PutMapping', '\Elasticsearch\Endpoints\Indices\Mapping\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetSettings', '\Elasticsearch\Endpoints\Indices\Settings\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\PutSettings', '\Elasticsearch\Endpoints\Indices\Settings\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetTemplate', '\Elasticsearch\Endpoints\Indices\Template\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\PutTemplate', '\Elasticsearch\Endpoints\Indices\Template\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\ExistsTemplate', '\Elasticsearch\Endpoints\Indices\Template\Exists'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\DeleteTemplate', '\Elasticsearch\Endpoints\Indices\Template\Delete'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\ExistsType', '\Elasticsearch\Endpoints\Indices\Type\Exists'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\GetUpgrade', '\Elasticsearch\Endpoints\Indices\Upgrade\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\Upgrade', '\Elasticsearch\Endpoints\Indices\Upgrade\Post'); | ||
class_alias('\Elasticsearch\Endpoints\Indices\ValidateQuery', '\Elasticsearch\Endpoints\Indices\Validate\Query'); | ||
class_alias('\Elasticsearch\Endpoints\Ingest\DeletePipeline', '\Elasticsearch\Endpoints\Ingest\Pipeline\Delete'); | ||
class_alias('\Elasticsearch\Endpoints\Ingest\GetPipeline', '\Elasticsearch\Endpoints\Ingest\Pipeline\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Ingest\PutPipeline', '\Elasticsearch\Endpoints\Ingest\Pipeline\Put'); | ||
class_alias('\Elasticsearch\Endpoints\Ingest\ProcessorGrok', '\Elasticsearch\Endpoints\Ingest\Pipeline\ProcessorGrok'); | ||
class_alias('\Elasticsearch\Endpoints\Mtermvectors', '\Elasticsearch\Endpoints\MTermVectors'); | ||
class_alias('\Elasticsearch\Endpoints\GetScript', '\Elasticsearch\Endpoints\Script\Get'); | ||
class_alias('\Elasticsearch\Endpoints\PutScript', '\Elasticsearch\Endpoints\Script\Put'); | ||
class_alias('\Elasticsearch\Endpoints\DeleteScript', '\Elasticsearch\Endpoints\Script\Delete'); | ||
class_alias('\Elasticsearch\Endpoints\Snapshot\CreateRepository', '\Elasticsearch\Endpoints\Snapshot\Repository\Create'); | ||
class_alias('\Elasticsearch\Endpoints\Snapshot\DeleteRepository', '\Elasticsearch\Endpoints\Snapshot\Repository\Delete'); | ||
class_alias('\Elasticsearch\Endpoints\Snapshot\GetRepository', '\Elasticsearch\Endpoints\Snapshot\Repository\Get'); | ||
class_alias('\Elasticsearch\Endpoints\Snapshot\VerifyRepository', '\Elasticsearch\Endpoints\Snapshot\Repository\Verify'); | ||
class_alias('\Elasticsearch\Endpoints\GetSource', '\Elasticsearch\Endpoints\Source\Get'); | ||
class_alias('\Elasticsearch\Endpoints\ExistsSource', '\Elasticsearch\Endpoints\Source\Exists'); | ||
class_alias('\Elasticsearch\Endpoints\Tasks\ListTasks', '\Elasticsearch\Endpoints\Tasks\TasksList'); | ||
class_alias('\Elasticsearch\Endpoints\Termvectors', '\Elasticsearch\Endpoints\TermVectors'); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Elasticsearch\Tests; | ||
|
||
/** | ||
* Class BackwardCompatibleTest | ||
* | ||
* @category Tests | ||
* @package Elasticsearch | ||
* @subpackage Tests | ||
* @author Enrico Zimuel <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
class BackwardCompatibleTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* List of endpoints in elasticsearch-php 7.2 branch | ||
*/ | ||
public function getClasses() | ||
{ | ||
return [ | ||
['Elasticsearch\Endpoints\MTermVectors'], | ||
['Elasticsearch\Endpoints\Tasks\Get'], | ||
['Elasticsearch\Endpoints\Tasks\Cancel'], | ||
['Elasticsearch\Endpoints\Tasks\TasksList'], | ||
['Elasticsearch\Endpoints\Ping'], | ||
['Elasticsearch\Endpoints\ScriptsPainlessExecute'], | ||
['Elasticsearch\Endpoints\DeleteByQuery'], | ||
['Elasticsearch\Endpoints\Scroll'], | ||
['Elasticsearch\Endpoints\Explain'], | ||
['Elasticsearch\Endpoints\Get'], | ||
['Elasticsearch\Endpoints\UpdateByQueryRethrottle'], | ||
['Elasticsearch\Endpoints\Delete'], | ||
['Elasticsearch\Endpoints\SearchShards'], | ||
['Elasticsearch\Endpoints\Mget'], | ||
['Elasticsearch\Endpoints\Source\Get'], | ||
['Elasticsearch\Endpoints\Source\Exists'], | ||
['Elasticsearch\Endpoints\Bulk'], | ||
['Elasticsearch\Endpoints\Cluster\PendingTasks'], | ||
['Elasticsearch\Endpoints\Cluster\Health'], | ||
['Elasticsearch\Endpoints\Cluster\Settings\Get'], | ||
['Elasticsearch\Endpoints\Cluster\Settings\Put'], | ||
['Elasticsearch\Endpoints\Cluster\Reroute'], | ||
['Elasticsearch\Endpoints\Cluster\State'], | ||
['Elasticsearch\Endpoints\Cluster\RemoteInfo'], | ||
['Elasticsearch\Endpoints\Cluster\Stats'], | ||
['Elasticsearch\Endpoints\Cluster\AllocationExplain'], | ||
['Elasticsearch\Endpoints\ClearScroll'], | ||
['Elasticsearch\Endpoints\Script\Get'], | ||
['Elasticsearch\Endpoints\Script\Delete'], | ||
['Elasticsearch\Endpoints\Script\Put'], | ||
['Elasticsearch\Endpoints\Exists'], | ||
['Elasticsearch\Endpoints\Index'], | ||
['Elasticsearch\Endpoints\UpdateByQuery'], | ||
['Elasticsearch\Endpoints\Ingest\Pipeline\Get'], | ||
['Elasticsearch\Endpoints\Ingest\Pipeline\Delete'], | ||
['Elasticsearch\Endpoints\Ingest\Pipeline\Put'], | ||
['Elasticsearch\Endpoints\Ingest\Pipeline\ProcessorGrok'], | ||
['Elasticsearch\Endpoints\Ingest\Simulate'], | ||
['Elasticsearch\Endpoints\SearchTemplate'], | ||
['Elasticsearch\Endpoints\FieldCaps'], | ||
['Elasticsearch\Endpoints\Snapshot\Get'], | ||
['Elasticsearch\Endpoints\Snapshot\Delete'], | ||
['Elasticsearch\Endpoints\Snapshot\Restore'], | ||
['Elasticsearch\Endpoints\Snapshot\Create'], | ||
['Elasticsearch\Endpoints\Snapshot\Status'], | ||
['Elasticsearch\Endpoints\Snapshot\Repository\Verify'], | ||
['Elasticsearch\Endpoints\Snapshot\Repository\Get'], | ||
['Elasticsearch\Endpoints\Snapshot\Repository\Delete'], | ||
['Elasticsearch\Endpoints\Snapshot\Repository\Create'], | ||
['Elasticsearch\Endpoints\Count'], | ||
['Elasticsearch\Endpoints\Create'], | ||
['Elasticsearch\Endpoints\Info'], | ||
['Elasticsearch\Endpoints\Indices\Type\Exists'], | ||
['Elasticsearch\Endpoints\Indices\ForceMerge'], | ||
['Elasticsearch\Endpoints\Indices\Flush'], | ||
['Elasticsearch\Endpoints\Indices\Analyze'], | ||
['Elasticsearch\Endpoints\Indices\Rollover'], | ||
['Elasticsearch\Endpoints\Indices\Get'], | ||
['Elasticsearch\Endpoints\Indices\Template\Get'], | ||
['Elasticsearch\Endpoints\Indices\Template\Delete'], | ||
['Elasticsearch\Endpoints\Indices\Template\Exists'], | ||
['Elasticsearch\Endpoints\Indices\Template\Put'], | ||
['Elasticsearch\Endpoints\Indices\Delete'], | ||
['Elasticsearch\Endpoints\Indices\FlushSynced'], | ||
['Elasticsearch\Endpoints\Indices\Refresh'], | ||
['Elasticsearch\Endpoints\Indices\Exists'], | ||
['Elasticsearch\Endpoints\Indices\Cache\Clear'], | ||
['Elasticsearch\Endpoints\Indices\Settings\Get'], | ||
['Elasticsearch\Endpoints\Indices\Settings\Put'], | ||
['Elasticsearch\Endpoints\Indices\Create'], | ||
['Elasticsearch\Endpoints\Indices\Close'], | ||
['Elasticsearch\Endpoints\Indices\ShardStores'], | ||
['Elasticsearch\Endpoints\Indices\Stats'], | ||
['Elasticsearch\Endpoints\Indices\Validate\Query'], | ||
['Elasticsearch\Endpoints\Indices\Alias\Get'], | ||
['Elasticsearch\Endpoints\Indices\Alias\Delete'], | ||
['Elasticsearch\Endpoints\Indices\Alias\Exists'], | ||
['Elasticsearch\Endpoints\Indices\Alias\Put'], | ||
['Elasticsearch\Endpoints\Indices\Open'], | ||
['Elasticsearch\Endpoints\Indices\Segments'], | ||
['Elasticsearch\Endpoints\Indices\Upgrade\Get'], | ||
['Elasticsearch\Endpoints\Indices\Upgrade\Post'], | ||
['Elasticsearch\Endpoints\Indices\Aliases\Update'], | ||
['Elasticsearch\Endpoints\Indices\Recovery'], | ||
['Elasticsearch\Endpoints\Indices\Shrink'], | ||
['Elasticsearch\Endpoints\Indices\Split'], | ||
['Elasticsearch\Endpoints\Indices\Mapping\Get'], | ||
['Elasticsearch\Endpoints\Indices\Mapping\Put'], | ||
['Elasticsearch\Endpoints\Indices\Mapping\GetField'], | ||
['Elasticsearch\Endpoints\Reindex'], | ||
['Elasticsearch\Endpoints\DeleteByQueryRethrottle'], | ||
['Elasticsearch\Endpoints\MsearchTemplate'], | ||
['Elasticsearch\Endpoints\TermVectors'], | ||
['Elasticsearch\Endpoints\AbstractEndpoint'], | ||
['Elasticsearch\Endpoints\RenderSearchTemplate'], | ||
['Elasticsearch\Endpoints\Update'], | ||
['Elasticsearch\Endpoints\Search'], | ||
['Elasticsearch\Endpoints\ReindexRethrottle'], | ||
['Elasticsearch\Endpoints\RankEval'], | ||
['Elasticsearch\Endpoints\Msearch'], | ||
['Elasticsearch\Endpoints\Cat\ThreadPool'], | ||
['Elasticsearch\Endpoints\Cat\Fielddata'], | ||
['Elasticsearch\Endpoints\Cat\Master'], | ||
['Elasticsearch\Endpoints\Cat\NodeAttrs'], | ||
['Elasticsearch\Endpoints\Cat\Aliases'], | ||
['Elasticsearch\Endpoints\Cat\PendingTasks'], | ||
['Elasticsearch\Endpoints\Cat\Templates'], | ||
['Elasticsearch\Endpoints\Cat\Allocation'], | ||
['Elasticsearch\Endpoints\Cat\Plugins'], | ||
['Elasticsearch\Endpoints\Cat\Health'], | ||
['Elasticsearch\Endpoints\Cat\Count'], | ||
['Elasticsearch\Endpoints\Cat\Shards'], | ||
['Elasticsearch\Endpoints\Cat\Repositories'], | ||
['Elasticsearch\Endpoints\Cat\Nodes'], | ||
['Elasticsearch\Endpoints\Cat\Tasks'], | ||
['Elasticsearch\Endpoints\Cat\Segments'], | ||
['Elasticsearch\Endpoints\Cat\Help'], | ||
['Elasticsearch\Endpoints\Cat\Recovery'], | ||
['Elasticsearch\Endpoints\Cat\Snapshots'], | ||
['Elasticsearch\Endpoints\Cat\Indices'] | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider getClasses | ||
*/ | ||
public function testOldClassNamespacesPreviousTo72($class) | ||
{ | ||
$this->assertTrue(class_exists($class), sprintf("Class %s does not exist", $class)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 alias is not needed, same name on both sides
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.
Case has changed. But I'm not sure if class names are case sensitive.
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.
@thePanz is right here. The alias cannot be done for case sensitive, since classes are case insensitive in PHP (even if the autoloading of composer is case sensitive). I'll just reuse the old class naming convention here.