Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 11.

Changes will periodically be added to this issue that remove deprecated API uses. To stop further changes from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD11" tag from the issue to stop the bot from posting updates.

The changes will be posted by the Project Update Bot official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated changes until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD11" tag is left on this issue, new changes will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the changes posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot changes. The bot will still post new changes then if there is a change in the new generated patch compared to the changes that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated changes.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated changes, remove the "ProjectUpdateBotD11" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated changes again, add back the "ProjectUpdateBotD11" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated changes will be posted here.

    If the issue is reopened, then new automated changes will be posted.

    If you are using another issue(s) to work on Drupal 11 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Using the merge request

  1. Review the merge request and test it.
  2. Thoroughly test the changes. These changes are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the merge request, create a new branch and merge request and work from there.

Warning: The 'project-update-bot-only' branch will always be overwritten. Do not work in that branch!

Providing feedback

If there are problems with one of the changes posted by the Project Update Bot, such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue. For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Project Update Bot created an issue. See original summary.

project update bot’s picture

Status: Active » Needs review
StatusFileSize
new750 bytes

This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request is also openend and updated.

It is important that any automated tests available are run and that you manually test the changes.

Drupal 11 Compatibility

According to the Upgrade Status module these changes make this module compatible with Drupal 11! 🎉
Therefore these changes update the info.yml file for Drupal 11 compatibility.

Leaving this issue open, even after committing the current patch, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

Debug info

Bot run #11-121090

This patch was created using these packages:

  1. drupal/upgrade_status: 4.1.0
  2. mglaman/phpstan-drupal: 1.2.7
  3. palantirnet/drupal-rector: 0.20.1

abhi_khandelwal made their first commit to this issue’s fork.

benstallings’s picture

Issue summary: View changes

I'm unable to install this fork in D11 with composer due to its dependency on flysystem v2 which is not D11 compatible. It needs to be dependent on version 3, or at least this MR: https://git.drupalcode.org/issue/flysystem-3451092/-/tree/fix-merge-error

shashi_shekhar_18oct’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new10.87 KB

MR!21 Makes this module compatible with Drupal 11. Functionality is working as expected.

RTBC +1

benstallings’s picture

Status: Reviewed & tested by the community » Needs work

@shashi_shekhar_18oct as I said above, the dependency on version 2.0 of flysystem module, which does not support Drupal 11, means that this version of flysystem_s3 cannot be installed with composer into a Drupal 11 site. This module needs to be made dependent on a version of flysystem that supports D11.

project update bot’s picture

Version: 2.1.2 » 2.1.x-dev
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new80 bytes
new738 bytes

This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

It is important that any automated tests available are run and that you manually test the changes.

Drupal 11 Compatibility

According to the Upgrade Status module these changes make this module compatible with Drupal 11! 🎉
Therefore these changes update the info.yml file for Drupal 11 compatibility.

Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

Debug information

Bot run #11-392907

These packages were used to generate the fixes:

  1. drupal/upgrade_status: 4.3.6
  2. mglaman/phpstan-drupal: 1.3.2
  3. palantirnet/drupal-rector: 0.20.3
benstallings’s picture

Issue summary: View changes

Looking at https://www.drupal.org/project/flysystem/issues/3378738 , it looks like there's no chance Flysystem v3 will be ready anytime soon, so I drop my objection. I'll see if I can make this work with the 2.2.x-dev MR at https://www.drupal.org/project/flysystem/issues/3433330 .

benstallings’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that MR!21 can now be installed with composer and enabled in Drupal 11.

gold’s picture

Hey all,

Any chance of getting this merged in and a release?

Cheers.

benstallings’s picture

I'm now seeing,

Call to deprecated method generateImageStyle() of class Drupal\flysystem_s3\Flysystem\S3. Deprecated in flysystem:2.2.0 and is removed from flysystem:3.0.0. Adapters should use generateImageUrl() to enable non-blocking image uploads.

on line 227 of S3.php. I'll see if I can fix it.

w01f’s picture

Following up on this. I'm looking to try and use flysystem for S3 in a new D11 project and avoiding drupal-lenient unless absolutely necessary =).

eli-t’s picture

Version: 2.1.x-dev » 2.2.x-dev
eli-t’s picture

Status: Reviewed & tested by the community » Needs work
eli-t’s picture

Version: 2.2.x-dev » 3.0.x-dev

On second thoughts, using 2.1.x for D10 and 2.2.x for D11 prevents us from ever having another D10 minor release, which is something we may possibly want to do. So let's use 3.0.x for D11.

eli-t’s picture

I've tried to push this along as far as I can today.

The only issue I'm currently aware of stopping this being merged and having a D11 release is that the PHPUnit job in CI is currently failing.

For example https://git.drupalcode.org/project/flysystem_s3/-/jobs/5464727

All the tests themselves pass, so I presume the job failing is due to the deprecations. I can't see the specifics of those in CI, but running locally I can see

❰elliot.ward❙~/code/d11test/d11/web/modules/contrib/flysystem_s3(git:3430648-d11_ready)❱✔≻ ddev exec phpunit -c web/core/phpunit.xml.dist web/modules/contrib/flysystem_s3
HTML output directory sites/simpletest/browser_output is not a writable directory.

PHPUnit 10.5.36 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.21
Configuration: /var/www/html/web/core/phpunit.xml.dist

DD.D......                                                        10 / 10 (100%)

Time: 00:02.496, Memory: 20.00 MB

3 tests triggered 5 deprecations:

1) /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:341
Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\flysystem\ImageStyleCopier" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by:

* Drupal\Tests\flysystem_s3\Functional\ModuleInstallUninstallWebTest::testInstallationAndUninstallation
  /var/www/html/web/modules/contrib/flysystem/tests/src/Functional/ModuleInstallUninstallWebTest.php:27

2) /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:341
Method "Aws\CacheInterface::get()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Drupal\flysystem_s3\AwsCacheAdapter" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by:

* Drupal\Tests\flysystem_s3\Unit\AwsCacheAdapterTest::testBasicGetSetDelete
  /var/www/html/web/modules/contrib/flysystem_s3/tests/src/Unit/AwsCacheAdapterTest.php:20

3) /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:341
Method "League\Flysystem\AwsS3v3\AwsS3Adapter::has()" might add "bool" as a native return type declaration in the future. Do the same in child class "Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by:

* Drupal\Tests\flysystem_s3\Unit\Flysystem\S3Test::testGetExternalUrl
  /var/www/html/web/modules/contrib/flysystem_s3/tests/src/Unit/Flysystem/S3Test.php:61

4) /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:341
Method "League\Flysystem\AwsS3v3\AwsS3Adapter::getMetadata()" might add "false|array" as a native return type declaration in the future. Do the same in child class "Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by:

* Drupal\Tests\flysystem_s3\Unit\Flysystem\S3Test::testGetExternalUrl
  /var/www/html/web/modules/contrib/flysystem_s3/tests/src/Unit/Flysystem/S3Test.php:61

5) /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:341
Method "League\Flysystem\AwsS3v3\AwsS3Adapter::upload()" might add "array|bool" as a native return type declaration in the future. Do the same in child class "Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by:

* Drupal\Tests\flysystem_s3\Unit\Flysystem\S3Test::testGetExternalUrl
  /var/www/html/web/modules/contrib/flysystem_s3/tests/src/Unit/Flysystem/S3Test.php:61

OK, but there were issues!
Tests: 10, Assertions: 27, Deprecations: 5.

These deprecations do not seem to be raised on D10 / flysystem_s3 2.1.x / phpunit 9.

I probably won't get time to look at this again in the nearish future, so if anyone is requiring a D11 release, the best thing you can do to move this issue forward is to look at why PHPunit is failing in CI.

w01f’s picture

Here's a pass at a patch for the 2 deprecation issues I see in flysystem_s3, for AwsCacheAdapter.php and S3Adapter.php - the remaining deprecation for the ImageStyleCopier.php file in the core flysystem module.

benstallings’s picture

When I run phpunit on my local, it complains about a bunch of missing composer dependencies. One at a time, of course. If I require each of them, I eventually get

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Drupal\Tests\flysystem_s3\Unit\Flysystem\S3Test::__construct(), 0 passed in /var/www/html/vendor/phpunit/phpunit/src/Framework/TestBuilder.php on line 138 and exactly 1 expected in /var/www/html/web/modules/composer/flysystem_s3/tests/src/Unit/Flysystem/S3Test.php:48

benstallings’s picture

Now I'm getting,

1) Drupal\Tests\flysystem_s3\Unit\AwsCacheAdapterTest::testBasicGetSetDelete
Failed asserting that false is null.

w01f’s picture

Swapping false for null should resolve that, ensuring AwsCacheAdapter::get() returns null (instead of false) when an item is not found. This should make the “assert null on a cache‐miss” pass again.

--- a/src/AwsCacheAdapter.php
+++ b/src/AwsCacheAdapter.php
@@ -38,7 +38,7 @@ class AwsCacheAdapter implements CacheInterface {
public function get(string $key): mixed {
if ($item = $this->cache->get($this->prefix . $key)) {
return $item->data;
}
- return false;
+ return null;
}

public function set(string $key, mixed $value): void {

eli-t’s picture

Thanks for all the ongoing work on this.

Just want to remind folks we need to use FALSE and NULL rather than false and null for coding standards!

w01f’s picture

@benstallings

I think @eli-t's comment means it should be:

--- a/src/AwsCacheAdapter.php
+++ b/src/AwsCacheAdapter.php
@@ -38,7 +38,7 @@ class AwsCacheAdapter implements CacheInterface {
public function get(string $key): mixed {
if ($item = $this->cache->get($this->prefix . $key)) {
return $item->data;
}
- return false;
+ return NULL;
}

public function set(string $key, mixed $value): void {

benstallings’s picture

OK, but I had already made that change in the MR before either of you commented about it. So the error message must be due to something else.

benstallings’s picture

So I capitalized null in the test as well, and now I don't understand what phpunit is saying about why it is failing.

w01f’s picture

Posted a related deprecation patch for core flysystem's ImageStyleCopier.php file in the 3.0 D11-compatibility issue - I think that's the correct place.

eli-t’s picture

OK, but I had already made that change in the MR before either of you commented about it. So the error message must be due to something else.

Apologies - I didn't mean to be confusing.

The case change was unrelated to the PHPUnit failure - it was to do with failed PHPCS run in the validate stage of the pipeline after commit b19950b8 : https://git.drupalcode.org/issue/flysystem_s3-3430648/-/jobs/5477376

The validate stage is now passing again following commit a7d997cb .

eli-t’s picture

Status: Needs work » Needs review

Looks like the deprecations about which phpunit was complaining were in the custom phpunit.xml.dist file supplied with this project.

The merge pipeline now passes with that file removed.

PHPunit says we have 10 tests and 26 assertions all passing with this removed.
These are the same totals as before the phpunit.xml.dist was removed, so it looks like this file was unnecessary.

I am not aware of any more issues with this merge request.

eli-t’s picture

Testing with flysystem 2.3.x and this MR, I can successfully upload image field images to S3.

However when trying to view such images I get error below.

Not sure if this is just a config issue on my test setup or a genuine D11 issue.

The website encountered an unexpected error. Try again later.

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "flysystem.image_style_redirect.serve" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 208 of core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\UrlGenerator->getRoute() (Line: 269)
Drupal\Core\Routing\UrlGenerator->generateFromRoute() (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (Line: 96)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generate() (Line: 94)
Drupal\flysystem_s3\Flysystem\S3->generateImageUrl() (Line: 227)
Drupal\flysystem_s3\Flysystem\S3->getExternalUrl() (Line: 75)
Drupal\flysystem\FlysystemBridge->getExternalUrl() (Line: 103)
Drupal\Core\File\FileUrlGenerator->doGenerateString() (Line: 66)
Drupal\Core\File\FileUrlGenerator->generateAbsoluteString() (Line: 255)
Drupal\image\Entity\ImageStyle->buildUrl() (Line: 302)
.
.
.
eli-t’s picture

Setting up with Drupal 10, flysystem 2.2.0-beta2 and flysystem_s3 2.1.3 and exactly the same settings.php configuration for flysystem works without the issue in comment #30 so this doesn't look like config, and does look like an outstanding D11 issue in either flysystem or flysystem_s3.

eli-t’s picture

Status: Needs review » Needs work
eli-t’s picture

This issue is due to flysystem_s3 swapping out the deprecated \Drupal\flysystem\Plugin\ImageStyleGenerationTrait::generateImageStyle() for its nominated replacement generateImageUrl().

generateImageUrl() relies on the presence of the flysystem.image_style_redirect.serve route, which doesn't appear to always be dynamically generated:

return \Drupal::urlGenerator()->generate('flysystem.image_style_redirect.serve', $args, UrlGeneratorInterface::ABSOLUTE_URL);

flysystem_s3 will have to revert to the old function, and inform phpstan to ignore this deprecation.

This will stop flysystem_s3 from being compatible with flysystem 3.0.x until it is resolved.

eli-t’s picture

Adding credits

  • ea73b0b3 committed on 3.0.x
    #3430648: 🐛  revert use of getImageUrl() with getImageStyle()....

  • 4a1d13f9 committed on 3.0.x
    #3430648: ✅   test removing custom phpunit configuration file.
    

  • 6ff00881 committed on 3.0.x
    #3430648: ✅   set displayDetailsOnAllIssues to true in phpunit...

  • f043302b committed on 3.0.x
    #3430648: 🔀   manual merge of 3.0.x to branch.
    

  • b1305e1d committed on 3.0.x
    #3430648: ✅   pass $name constructor to parent when constructing...

  • 0aaaa4a4 committed on 3.0.x
    #3430648: 👷‍♂️  do not run CI against previous major - this version of...

  • c5d94211 committed on 3.0.x
    #3430648: require drupal/flysystem ^2.3 and hence Drupal ^11 for...
eli-t’s picture

Status: Needs work » Fixed

Well done everyone! We got there in the end.

New release 3.0.0 coming imminently.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bradjones1’s picture

The issue in #33 is, AFAICT, actually a regression in Flysystem relating to image style generation with non-local/remote adapters. So this was early smoke from that regression. See #3513799: Regression: Image style generation no longer works for non-local drivers.