Skip to main content

To get Flysystem S3 ready for Drupal 10, I needed to apply the latest patch to the contrib module - Flysystem S3 (https://www.drupal.org/project/flysystem_s3).

Rather than using the current RC (2.0.0-rc5) release, which was released 25 March 2022.  Instead, I'll be using the dev release -  2.0.x-dev updated 14 Aug 2023.

The patch I'll be using is from the issues area - Automated Drupal 10 compatibility fixes... go to https://www.drupal.org/project/flysystem_s3/issues/3297257#comment-15218438

Download the patch and prepare to be applied via Composer JSON file.

 

How do you apply a patch?

Save the patch to your root directory.  To keep the patches organised, I've create a directory named patches.

patches
  - flysystem_s3-d10compatibility-3297257-15.patch

In the composer.json file, the extra area will be something similar to

    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"]
        }
    }

Beneath installer-path, add:

  • composer-exit-on-patch-failure
  • patchLevel
  • patches

As an example:

    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"]
        },
        "composer-exit-on-patch-failure": true,
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": {
        }
    }

In patches, we need to point Flysystem S3 to the patch.  Let Drupal know the module that will be patched - drupal/flysystem_s3.  And the path/filename to the patch... patches/flysystem_s3-d10compatibility-3297257-15.patch.  Putting this together and it will look like:

"drupal/flysystem_s3": {
    "config import ids": "patches/flysystem_s3-d10compatibility-3297257-15.patch"
},
            

 

Using the parent extra as noted earlier, it's children now appears as

    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"]
        },
        "composer-exit-on-patch-failure": true,
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": {
            "drupal/flysystem_s3": {
                "config import ids": "patches/flysystem_s3-d10compatibility-3297257-15.patch"
            }
        }
    }

 

Related articles

Andrew Fletcher04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...