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

Introducing PHP8 compliancy #1063

Merged
merged 4 commits into from
Dec 10, 2020
Merged

Conversation

giovannialbero1992
Copy link
Contributor

No description provided.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

composer.json Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
.ci/packer_cache.sh Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@deguif
Copy link

deguif commented Oct 22, 2020

@ezimuel Is there anything we can do to help moving this forward.

ruflin/elastica added support for PHP 8.0 recently but had to skip platform requirements while testing in its CI as elasticsearch/elasticsearch doesn't support PHP 8.0 in its composer requirement.

I think this should target branch 7.x?

@mfn
Copy link

mfn commented Nov 16, 2020

The title of the PR

Introducing PHP8 compliancy

I'm starting to test run this library on PHP 8 in my company and found some issues (using v7.10.0) but was surprised this PR does not touch any of the code parts I saw errors 🤷‍♀️

For example, without a vendor patch hack I can't connect at all:

ErrorException: Elasticsearch\Connections\Connection::Elasticsearch\Connections\{closure}(): Argument #2 ($key) must be passed by reference, value given

/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:358
/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:218
/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php:110
/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php:1637
/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php:310

In this case this is the diff for the "fix" (removed the unused ❗ &$key variable) in

Index: vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php b/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php
--- a/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php	(revision 8f1256488b3c58bec0e3027bbc4d74a2408204f0)
+++ b/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php	(revision 1c323624f0f741645ab9af0c66d6deffd01553e9)
@@ -349,7 +349,7 @@
         if (isset($params) === true && !empty($params)) {
             array_walk(
                 $params,
-                function (&$value, &$key) {
+                function (&$value) {
                     if ($value === true) {
                         $value = 'true';
                     } elseif ($value === false) {

Anyone else seeing this? Should I create an issue or PR directly? I'm just not sure as it seems these tests here seem to be green on PHP 8 nevertheless.

I'm also running tests on GHA using setup-php but I did run them recently, so maybe it's a new regression (or it's just simply not covered in the suite 🤷‍♀️)

Thanks

@deguif
Copy link

deguif commented Nov 16, 2020

@mfn good catch.
See https://3v4l.org/ZmrdO to confirm that the code underlined by @mfn is breaking in PHP 8.

@mfn
Copy link

mfn commented Nov 16, 2020

Smart 😄 Thank you @deguif 🙇

@deguif
Copy link

deguif commented Nov 16, 2020

@mfn this should also be fixed by #1075

@mfn
Copy link

mfn commented Nov 16, 2020

@deguif Thank you, I confirmed it #1075 (comment) !

@ezimuel
Copy link
Contributor

ezimuel commented Nov 16, 2020

@giovannialbero1992, @deguif, @mfn, @OskarStark thanks for your contribution! I'll update soon, thanks!

@pascaldevink
Copy link
Contributor

pascaldevink commented Nov 26, 2020

@ezimuel @deguif PHP 8 was released today, is there any update on the progress of this PR?

@reedy
Copy link
Contributor

reedy commented Dec 2, 2020

I guess with 8.0 being table, we shouldn't need to use RC4 anymore (I'm presuming newer images exist)...

@giovannialbero1992
Copy link
Contributor Author

Hi @reedy, I updated the image used 😃

@ezimuel
Copy link
Contributor

ezimuel commented Dec 9, 2020

Hi @giovannialbero1992 sorry for the delay, I finally have some time to review the PR. I noticed that you sent it to master, can you rebase and sent to 7.x branch? Thanks!

@giovannialbero1992 giovannialbero1992 changed the base branch from master to 7.x December 9, 2020 15:17
@ezimuel
Copy link
Contributor

ezimuel commented Dec 9, 2020

@giovannialbero1992 I fixed some PHP 8 compatibility issues:

  • added version 3 of cpliakas/git-wrapper in composer;
  • removed the annotation for expecting exceptions in ClientBuilderTest.php, for PHPUnit 9.

Moreover, I reintroduced the support of PHP 7.1, we still need to support it 😱 until next major of elasticsearch-php.

@ezimuel ezimuel merged commit 14050c3 into elastic:7.x Dec 10, 2020
@ezimuel
Copy link
Contributor

ezimuel commented Dec 10, 2020

Welcome PHP 8!!!

@mfn
Copy link

mfn commented Dec 10, 2020

Awesome!

FTR, I won't be really working with PHP8 until #1075 is in, too!

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

Successfully merging this pull request may close these issues.

8 participants