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

Aliases might be incompartible with PHP 7.4 Preloading feature #1976

Closed
Ttakeleif opened this issue Oct 26, 2020 · 15 comments · Fixed by #1978
Closed

Aliases might be incompartible with PHP 7.4 Preloading feature #1976

Ttakeleif opened this issue Oct 26, 2020 · 15 comments · Fixed by #1978
Assignees
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial.

Comments

@Ttakeleif
Copy link

Environment details

  • OS: docker php:7.4-fpm
  • PHP version: php:7.4
  • Package name and version: latest (2.8.0)

Steps to reproduce

I have an issue with aliases in Symfony app optimized for PHP 7.4 preloading feature. It loads all the required classes at once and conflicts with the aliases file which leads to numerous errors like

Cannot declare class Google_Http_REST, because the name is already in use in /app/vendor/google/apiclient/src/aliases.php on line 27

Could you please make it optional or add checking that those classes are not defined yet?

For those who have the same issue possible solutions are

  • stick to 2.7.x (unfortunately not my case because I use it indirectly via lib with dependency like ^2.x)
  • in a build script wipe out aliases file with echo '<?php' > ./vendor/google/apiclient/src/aliases.php
@mfn
Copy link

mfn commented Oct 27, 2020

stick to 2.7.x (unfortunately not my case because I use it indirectly via lib with dependency like ^2.x)

Btw you can still "fix" this yourself my (temporary) making it a root dependency in your project for 2.7, so you wouldn't have to resort the build step. At least I would like to think so that this should work.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Oct 27, 2020
@Ttakeleif
Copy link
Author

@mfn I solved the conflict by adding

    "require": {
        "google/apiclient": "2.7.2 as 2.8.0"
    }

to composer.json. Though I have to retest the functionality for any possible issues because of that blatant substitution 🤞 😄

@jdpedrie jdpedrie added status: investigating The issue is under investigation, which is determined to be non-trivial. and removed triage me I really want to be triaged. labels Oct 27, 2020
@bshaffer
Copy link
Contributor

bshaffer commented Oct 27, 2020

Thank you for reporting this, I will look into how to fix it. In the meantime, you can just require google/apiclient:2.7.2 rather than use an alias for 2.8.0 as you do above:

    "require": {
        "google/apiclient": "2.7.2"
    }

The issue with your transitive dependency is you need to remove composer.lock and vendor before updating with the above require.

@bshaffer
Copy link
Contributor

@Ttakeleif this is now fixed! Update to v.2.8.1 and you'll be all set!

@Ttakeleif
Copy link
Author

@bshaffer I can confirm the issue is fixed.

@snoogans235
Copy link

snoogans235 commented Nov 10, 2020

Does this mean the class_exists line in src/aliases.php is no longer needed?

Edit: Just saw this was the fix for this issue. I'm still getting a problem while running docker container php7.4-apache. I am able to avoid the issue by using 2.8.0 though.

@bshaffer
Copy link
Contributor

@snoogans235 is it possible this will fix your issue?

#1991

@aliemam
Copy link

aliemam commented Dec 24, 2020

@bshaffer Is this solved in 2.8.3? because I still get the warnings.
PHP Warning: Can't preload already declared class Google_Utils_UriTemplate

@kursez
Copy link

kursez commented Dec 30, 2020

I got the same issue again for 2.8.3

@eugenekurasov
Copy link

eugenekurasov commented Feb 23, 2021

After merge PR preload send warnings.
#1995

@nmeirik
Copy link

nmeirik commented Jun 5, 2021

I'm not sure that this fix has been sufficient. I am running v. 2.9.1 of "google/apiclient" and I get the following output:

  Can't preload already declared class Google_Utils_UriTemplate in /code/platform/vendor/go
 ogle/apiclient/src/aliases.php on line 64
  Can't preload already declared class Google_Task_Runner in /code/platform/vendor/google/a
 piclient/src/aliases.php on line 63
  Can't preload already declared class Google_Task_Retryable in /code/platform/vendor/googl
 e/apiclient/src/aliases.php on line 62
  Can't preload already declared class Google_Task_Exception in /code/platform/vendor/googl
 e/apiclient/src/aliases.php on line 61
  Can't preload already declared class Google_Service_Resource in /code/platform/vendor/goo
 gle/apiclient/src/aliases.php on line 60
  Can't preload already declared class Google_Service_Exception in /code/platform/vendor/go
 ogle/apiclient/src/aliases.php on line 59
  Can't preload already declared class Google_Service in /code/platform/vendor/google/apicl
 ient/src/aliases.php on line 58
  Can't preload already declared class Google_Model in /code/platform/vendor/google/apiclie
 nt/src/aliases.php on line 57
  Can't preload already declared class Google_Http_REST in /code/platform/vendor/google/api
 client/src/aliases.php on line 56
  Can't preload already declared class Google_Http_MediaFileUpload in /code/platform/vendor
 /google/apiclient/src/aliases.php on line 55
  Can't preload already declared class Google_Http_Batch in /code/platform/vendor/google/ap
 iclient/src/aliases.php on line 54
  Can't preload already declared class Google_Exception in /code/platform/vendor/google/api
 client/src/aliases.php on line 53
  Can't preload already declared class Google_Collection in /code/platform/vendor/google/ap
 iclient/src/aliases.php on line 52
  Can't preload already declared class Google_Client in /code/platform/vendor/google/apicli
 ent/src/aliases.php on line 51
  Can't preload already declared class Google_AuthHandler_Guzzle7AuthHandler in /code/platf
 orm/vendor/google/apiclient/src/aliases.php on line 50
  Can't preload already declared class Google_AuthHandler_Guzzle6AuthHandler in /code/platf
 orm/vendor/google/apiclient/src/aliases.php on line 49
  Can't preload already declared class Google_AuthHandler_Guzzle5AuthHandler in /code/platf
 orm/vendor/google/apiclient/src/aliases.php on line 48
  Can't preload already declared class Google_AuthHandler_AuthHandlerFactory in /code/platf
 orm/vendor/google/apiclient/src/aliases.php on line 47
  Can't preload already declared class Google_AccessToken_Verify in /code/platform/vendor/g
 oogle/apiclient/src/aliases.php on line 46

Can this issue perhaps be reopened?

@hakimio
Copy link

hakimio commented Jun 23, 2021

@nmeirik they fixed it in google\apiclient, but the same issue exists in google\apiclient-services library which is not fixed.
My bug report.

EDIT: seems to be an issue on my end. I had left-over directory after composer vendor directory upload.

@bshaffer
Copy link
Contributor

@nmeirik I missed your comment because this issue is closed. Were you able to get it resolved? If not can you open a new issue? Thanks.

@nmeirik
Copy link

nmeirik commented Jun 23, 2021

@bshaffer I realized that is was just a warning and not a blocker as I initially thought, so I moved on.

@rulatir
Copy link

rulatir commented Dec 6, 2021

There is no such thing as "warning and not a blocker". Whenever you have warnings AND ALSO a crash for which you seek support, the first question you'll get asked is "are there any warnings"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial.
Projects
None yet
Development

Successfully merging a pull request may close this issue.