google-api-php-client-services icon indicating copy to clipboard operation
google-api-php-client-services copied to clipboard

Modify autoload for hitting disc and checking is file existing

Open bojanpejic opened this issue 2 years ago • 5 comments

The autoload was originally introduced in Pull Request #363 for supporting legacy classes.

Main idea is to avoid hitting disc which is done with calling file_exists(__DIR__ . '/../apiclient/src/Google/Client.php') and looking for a file, which in case that a newer version of google/apiclient than 2.7.2 results with failing check, specifically it looks for file vendor/google/apiclient-services/../apiclient/src/Google/Client.php and that results with no such file or directory.

bojanpejic avatar Jan 03 '24 13:01 bojanpejic

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jan 03 '24 13:01 google-cla[bot]

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

image

bojanpejic avatar Jan 03 '24 13:01 bojanpejic

If I understand the problem correctly, I think the best solution would be to just move toa new major (3.0) version of this library and remove the legacy namespaces.

To which new major (3.0) version you are exactly referring?

bojanpejic avatar Jan 12 '24 14:01 bojanpejic

Ping @bshaffer ^ :)

umpirsky avatar Mar 11 '24 11:03 umpirsky

@bojanpejic it would be a new major version of the library we haven't released yet, where we would remove these autoload.php files.

bshaffer avatar May 17 '24 18:05 bshaffer

Just so we are clear, @bojanpejic and @umpirsky and anyone else following this PR...

If you update your code to use the new namespaces (e.g. Google\Client and Google\Service\ServiceName), these hits to disc will not happen. They only take place when using the LEGACY classnames (e.g. Google_Client and Google_Service_ServiceName)

bshaffer avatar May 17 '24 18:05 bshaffer

We updated the codebase to use new namespaces and we still see:

90220 php-fpm  RET   __getcwd 0
90220 php-fpm  CALL  access(0x73a8f48,0<F_OK>)
90220 php-fpm  NAMI  "/www/sites/.../vendor/google/apiclient-services/../apiclient/src/Google/Client.php"
90220 php-fpm  RET   access -1 errno 2 No such file or directory

umpirsky avatar Aug 06 '24 10:08 umpirsky