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

Issue bundling AWS S3 package #65

Closed
kodie opened this issue Apr 24, 2023 · 3 comments
Closed

Issue bundling AWS S3 package #65

kodie opened this issue Apr 24, 2023 · 3 comments

Comments

@kodie
Copy link

kodie commented Apr 24, 2023

I'm attempting to bundle the aws-sdk-php package in my plugin (specifically the S3 component) and am running into an odd issue.

Basically these files:

vendor/aws/aws-sdk-php/src/Endpoint/UseDualstackEndpoint/Configuration.php
vendor/aws/aws-sdk-php/src/Endpoint/UseFipsEndpoint/Configuration.php
vendor/aws/aws-sdk-php/src/S3/UseArnRegion/Configuration.php

all have a line that looks similar to this:

$this->useFipsEndpoint = Aws\boolean_value($useFipsEndpoint);

and after prefixing, they become something like this:

$this->useFipsEndpoint = MyPlugin\Vendor\Aws\boolean_value($useFipsEndpoint);

Which results in this error:

PHP Fatal error:  Uncaught Error: Call to undefined function MyPlugin\Vendor\Aws\Endpoint\UseFipsEndpoint\MyPlugin\Vendor\Aws\boolean_value() in /app/content/plugins/my-plugin/vendor-prefixed/aws/aws-sdk-php/src/Endpoint/UseFipsEndpoint/Configuration.php:20

If I manually add a backslash at the begining of these classes, like this:

$this->useFipsEndpoint = \MyPlugin\Vendor\Aws\boolean_value($useFipsEndpoint);

The issue goes away and everything works as expected.

Any ideas?

@kodie
Copy link
Author

kodie commented Apr 24, 2023

After looking at Mozart issues, I realized that this is the exact issue I ran into while trying to use it a little over a year ago: coenjacobs#62

@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Apr 27, 2023

Oops. I haven't solved this yet. (I did try the other day!)

@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Oct 30, 2023

That should be fixed in master now. I'm not 100% comfortable with the solution: db348bb

In your examples, if:

$this->useFipsEndpoint = Aws\boolean_value($useFipsEndpoint);

worked, then I would expect

$this->useFipsEndpoint = MyPlugin\Vendor\Aws\boolean_value($useFipsEndpoint);

to also work.

My solution was to search for MyPlugin\Vendor\Aws\boolean_value(, i.e. prefixed, namespaced function calls, and ensure there is always a leading \, as in your fix:

$this->useFipsEndpoint = \MyPlugin\Vendor\Aws\boolean_value($useFipsEndpoint);

It seems safe, but since I don't understand why the original syntax was working, I'm worried of unintended side effects.

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

No branches or pull requests

2 participants