Automated Drupal 11 compatibility fixes for flysystem_s3

Created on 17 March 2024, over 1 year ago
Updated 3 January 2025, 7 months ago

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 โ†’ .

๐Ÿ“Œ Task
Status

Needs review

Version

2.1

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @project update bot
  • 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
  • Pipeline finished with Success
    over 1 year ago
    Total: 201s
    #121594
  • First commit to issue fork.
  • Merge request !21Drupal 11 compatibility โ†’ (Merged) created by Unnamed author
  • Pipeline finished with Failed
    7 months ago
    Total: 138s
    #384535
  • Pipeline finished with Canceled
    7 months ago
    Total: 132s
    #384544
  • Pipeline finished with Failed
    7 months ago
    Total: 130s
    #384547
  • Pipeline finished with Success
    7 months ago
    Total: 173s
    #384570
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shashi_shekhar_18oct

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

    RTBC +1

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    @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.

  • 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
  • Pipeline finished with Success
    6 months ago
    Total: 216s
    #393428
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    Looking at https://www.drupal.org/project/flysystem/issues/3378738 ๐ŸŒฑ Planning for Release 3.0.0, Drupal 10.3+ Compatibility, Flysystem v3.1 Compatibility Needs work , 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 ๐Ÿ“Œ Automated Drupal 11 compatibility fixes for flysystem Needs review .

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

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

  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand Gold 20 minutes in the future

    Hey all,

    Any chance of getting this merged in and a release?

    Cheers.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    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.

  • Pipeline finished with Success
    3 months ago
    Total: 273s
    #482150
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States w01f

    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 =).

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States w01f

    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.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 245s
    #515445
  • Pipeline finished with Failed
    about 1 month ago
    Total: 146s
    #515460
  • Pipeline finished with Failed
    about 1 month ago
    Total: 153s
    #515466
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    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

  • Pipeline finished with Failed
    about 1 month ago
    Total: 155s
    #515480
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    Now I'm getting,

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

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States w01f

    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 {

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States w01f

    @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 {

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

    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.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 153s
    #519019
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States BenStallings

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

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States w01f

    Posted a related deprecation patch for core flysystem's ImageStyleCopier.php file in the 3.0 D11-compatibility issue ๐Ÿ“Œ Automated Drupal 11 compatibility fixes for flysystem Needs review - I think that's the correct place.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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 .

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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)
    .
    .
    .
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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 #3430648-31: Automated Drupal 11 compatibility fixes for flysystem_s3 โ†’ so this doesn't look like config, and either an outstanding D11 issue in flysystem or flysystem_s3.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    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...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Eli-T Manchester

    Well done everyone! We got there in the end.

    New release 3.0.0 coming imminently.

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

Production build 0.71.5 2024