Skip to content
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

[BUG] Client Builder is Deprecated #283

Closed
manuelKruesi opened this issue Feb 4, 2025 · 14 comments · Fixed by #295
Closed

[BUG] Client Builder is Deprecated #283

manuelKruesi opened this issue Feb 4, 2025 · 14 comments · Fixed by #295
Labels
documentation Improvements or additions to documentation untriaged

Comments

@manuelKruesi
Copy link

manuelKruesi commented Feb 4, 2025

What is the bug?

I used the clientBuilder to build my Client that handels my importing. This is my init code:

$this->client = \OpenSearch\ClientBuilder::fromConfig(array(
	'hosts' => array(
		$config['protocol'] . $host . ":" . $config['port']
	),
	'retries' => 2,
	'handler' => \OpenSearch\ClientBuilder::multiHandler()
));

This now leads to a deprecated warning in the ClientBuilder as well as in the AbstractNamespace
I was not able to find any change report as to with what i should replace the ClientBuilder.

How can one reproduce the bug?

Build a client with the above code

What is the expected behavior?

I should get a Client without any warnings

What is your host/environment?

Ubuntu 20.04

@manuelKruesi manuelKruesi added bug Something isn't working untriaged labels Feb 4, 2025
@icsdevs
Copy link

icsdevs commented Feb 4, 2025

Also getting this issue. If it is deprecated then the docs haven't been updated either so don't know what the new way is.

@dblock
Copy link
Member

dblock commented Feb 4, 2025

You're right, docs are missing, also per #257 (comment). Can someone please help? Working code in #271.

@kimpepper kimpepper added documentation Improvements or additions to documentation and removed bug Something isn't working untriaged labels Feb 5, 2025
@kimpepper
Copy link
Collaborator

The ClientBuilder is intentionally deprecated, and getting a deprecation warning is not a bug. You can continue to use it, but it will be removed in 3.0.0. This is a warning that it will go away, so gives you time to update your code to use the new approach. See https://github.com/opensearch-project/opensearch-php/blob/main/UPGRADING.md

@icsdevs
Copy link

icsdevs commented Feb 5, 2025

The ClientBuilder is intentionally deprecated, and getting a deprecation warning is not a bug. You can continue to use it, but it will be removed in 3.0.0. This is a warning that it will go away, so gives you time to update your code to use the new approach. See https://github.com/opensearch-project/opensearch-php/blob/main/UPGRADING.md

The documentation on the site needs updating then. See: https://opensearch.org/docs/latest/clients/php/#connecting-to-opensearch

@dblock
Copy link
Member

dblock commented Feb 5, 2025

I opened opensearch-project/documentation-website#9158 for that one. @icsdevs if you can help update the docs here and https://github.com/opensearch-project/documentation-website that would be grand.

@manuelKruesi
Copy link
Author

Thank you for the fast and thoughtful response. I will follow the linked instruction to rewrite my code following the new Guidelines. Thank you for your work on this valuable project!

@michal-swietochowski-tg
Copy link

I followed the upgrade but I still get:

PHP Deprecated: OpenSearch\Namespaces\AsyncSearchNamespace is deprecated in 2.4.0 and will be removed in 3.0.0. Use AsynchronousSearchNamespace instead. in /var/www/html/vendor/opensearch-project/opensearch-php/src/OpenSearch/Namespaces/AsyncSearchNamespace.php on line 25
PHP Deprecated: OpenSearch\Namespaces\DataFrameTransformDeprecatedNamespace is deprecated in 2.4.0 and will be removed in 3.0.0. in /var/www/html/vendor/opensearch-project/opensearch-php/src/OpenSearch/Namespaces/DataFrameTransformDeprecatedNamespace.php on line 25
PHP Deprecated: OpenSearch\Namespaces\MonitoringNamespace is deprecated in 2.4.0 and will be removed in 3.0.0. in /var/www/html/vendor/opensearch-project/opensearch-php/src/OpenSearch/Namespaces/MonitoringNamespace.php on line 27
PHP Deprecated: OpenSearch\Namespaces\SearchableSnapshotsNamespace is deprecated in 2.4.0 and will be removed in 3.0.0. in /var/www/html/vendor/opensearch-project/opensearch-php/src/OpenSearch/Namespaces/SearchableSnapshotsNamespace.php on line 25
PHP Deprecated: OpenSearch\Namespaces\SslNamespace is deprecated in 2.4.0 and will be removed in 3.0.0. Use SslNamespace instead. in /var/www/html/vendor/opensearch-project/opensearch-php/src/OpenSearch/Namespaces/SslNamespace.php on line 25

These classes are used in the constructor of \OpenSearch\Client so I am unable to get a Client without any warnings with this version :/

@kimpepper
Copy link
Collaborator

These classes are used in the constructor of \OpenSearch\Client so I am unable to get a Client without any warnings with this version :/

These are deprecation warnings not errors. They are informing you that these classes will be removed in 3.0.0.

@dblock
Copy link
Member

dblock commented Feb 6, 2025

@michal-swietochowski-tg See https://github.com/opensearch-project/opensearch-php/blob/main/UPGRADING.md for code to replace the deprecations with that will get rid of the warnings. Let us know if that works.

I'll close this since it's by design.

@dblock dblock closed this as completed Feb 6, 2025
@manuelKruesi
Copy link
Author

Unfortunately, this guide is not running code.

im using

"name": "opensearch-project/opensearch-php",
            "version": "2.4.0",

 "name": "guzzlehttp/guzzle",
            "version": "7.9.2",

and inserting this code

$client = (new \OpenSearch\GuzzleClientFactory())->create([
    'base_uri' => 'https://localhost:9200',
    'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')],
    'verify' => false,
]);

// Send a request to the 'info' endpoint.
$info = $client->info();

just results in the following:
Uncaught Error: Class "OpenSearch\GuzzleClientFactory" not found

From what I was able to see, this stems from the fact that the GuzzleClientFactory is not present in the 2.4.0 version
I can see that it exists in the current repo, but its not in the release.

I feel like these deprecated warning have been introtuced too early without a current working alternativ in the release.
Am I overlooking something?

I also tried the Guzzle Example in the 2.4.0 samples file but this also results in deprecated warnings (SslNamespace to be exact)

If im missing something I would be glad to hear about my shortcomings. Else I will wait for the next release

Thank you for your work and assistance!

@dblock
Copy link
Member

dblock commented Feb 7, 2025

You can always check docs at the 2.4.0 tag, at that version the UPGRADING.md is pretty clear.

@manuelKruesi
Copy link
Author

i see, i checked all the 2.4 versions except for the actual guide. thank you

@manuelKruesi
Copy link
Author

manuelKruesi commented Feb 10, 2025

I followed the guide at your repository and all possible ways (Except symfony) in this 2.4.0 samples

This does still produce deprecated warnings, because there are deprecated classes called in the Client in 2.4.0 on line:
302 (AsyncSearchNamespace),
307 (DataFrameTransformDeprecatedNamespace),
316 (MonitoringNamespace),
326 (SearchableSnapshotsNamespace),
329 (SnapshotNamespace),
331 (SslNamespace)

Since we are required to implement error and also warning free code, we are not able to upgrade to 2.4.0 since it does not meet our requirements.

Thank you for your answers and help, we will upgrade once 2.4.0 is warnings free or 2.5 releases with its new GuzzleClientFactory

@kimpepper
Copy link
Collaborator

I re-opened this as I opened #295 to look at suppressing some of the deprecation warnings and ensuring we deprecate the methods on the Client object appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants