Automated Drupal 11 compatibility fixes for flysystem_s3

Created on 17 March 2024, about 1 year ago
Updated 3 January 2025, 5 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
    about 1 year ago
    Total: 201s
    #121594
  • First commit to issue fork.
  • Merge request !21Drupal 11 compatibility → (Open) created by Unnamed author
  • Pipeline finished with Failed
    5 months ago
    Total: 138s
    #384535
  • Pipeline finished with Canceled
    5 months ago
    Total: 132s
    #384544
  • Pipeline finished with Failed
    5 months ago
    Total: 130s
    #384547
  • Pipeline finished with Success
    5 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
    5 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 3 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
    about 1 month 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 21 hours ago
    Total: 245s
    #515445
  • Pipeline finished with Failed
    about 21 hours ago
    Total: 146s
    #515460
  • Pipeline finished with Failed
    about 21 hours 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 21 hours 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 {

Production build 0.71.5 2024