akeeba / s3

No-dependencies, lightweight Amazon S3 connector implementation in pure PHP
37 stars 17 forks source link

PHP warnings after last update #31

Closed AlexTr closed 1 year ago

AlexTr commented 1 year ago
Warning: Class "Akeeba\S3\Acl" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Configuration" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Connector" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Input" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Request" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Response" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Signature" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\StorageClass" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotDeleteFile" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotGetBucket" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotGetFile" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotListBuckets" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotOpenFileForRead" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotOpenFileForWrite" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\CannotPutFile" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\ConfigurationError" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidAccessKey" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidBody" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidEndpoint" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidFilePointer" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidRegion" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidSecretKey" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\InvalidSignatureMethod" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Exception\PropertyNotFound" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Response\Error" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Signature\V2" not found in .../akeeba/s3/src/aliasing.php on line 45
Warning: Class "Akeeba\S3\Signature\V4" not found in .../akeeba/s3/src/aliasing.php on line 45

The problem is that if original class isn't loaded yet then class_alias in aliasing.php file will fail, since it's not pre-loading missing classes by default, changing class_alias to preload class fixes the problem, but it loads all classes upon composer autoload inclusion which maybe not desirable for speed reasons. It would be great if old class paths would be loaded by demand instead.

nikosdion commented 1 year ago

PHP cannot load class aliases on demand. Loading classes on demand only works with the autoloader, but the autoloader will only work if the original class (as requested) is found, unfortunately. If you know of another way to do that, please let me know.

AlexTr commented 1 year ago

@nikosdion thank you for the feedback, I mean call some function which will make aliasing for old paths with preloading (all the code in aliasing.php), so to migrate to new version without changing code, only one function will need to be called. Now unfortunately the library is broken, aliasing.php isn't working, it doesn't adding aliasing and generate errors.

nikosdion commented 1 year ago

It does not make sense having to call a function. If you have to make a change in your code you might just as well change the namespace. That's the whole point of the aliasing. I changed the code to do preloading and will release a new version.

nikosdion commented 1 year ago

FWIW the latest semantically versioned tag (2.2.2) predates the namespace change, i.e. the library was never broken. If you use it via composer with its semantically versioned releases you never saw it breaking. I have not released 2.3.0 yet.

The development branch is exactly that; under development. Occasionally things break. Just because I push into the branch doesn't mean it's working code. In this case I pushed code before traveling so my code is not just on a laptop which could get lost, broken etc. I just never had the chance to come back to this to test its integration with other software relying on the legacy namespace.

BTW, if you're using the development branch, the commit https://github.com/akeeba/s3/commit/a5dbdc2cc7d5aaaf30a69bdd3648baa45faf6d85 already fixed that problem so you're one composer update away from getting your downstream fixed.

AlexTr commented 1 year ago

Great, thank you @nikosdion