After upgrading a site to Drupal 9 and updating flysystem_s3 to 2.0.0-rc1 (which is supposed to have d9 support) I still get an error for a method that has changed since d8:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\flysystem_s3\File\FlysystemS3FileSystem::uriScheme() in Drupal\flysystem_s3\S3CorsManagedFileHelper::preProcessCors() (line 34 of modules/contrib/flysystem_s3/src/S3CorsManagedFileHelper.php).

In Drupal 9 \Drupal::service('file_system')->uriScheme() has been replaced with \Drupal::service('stream_wrapper_manager')->getScheme()

Heads up: this issue is tagged version 8.x-1.x-dev but it's patching 2.0.0 which wasn't available when creating the issue.

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

jascote created an issue. See original summary.

jascote’s picture

StatusFileSize
new779 bytes

Here's a patch to fix this for anyone upgrading to Drupal 9.

slasher13’s picture

Status: Active » Needs review
StatusFileSize
new2.21 KB

more replacements

kreynen’s picture

This patch worked for me.

achap’s picture

Patch works for me! Thanks :) Can any maintainers allow us to run the tests against the 2.x branch?

timkruijsen’s picture

StatusFileSize
new2.21 KB

I've changed the patch a bit so it works on the 2.x branch

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

lisa.rae’s picture

Issue version notes this patch is for 8.x-1.x, but the last note indicates that the patch for #6 is for the 8.x-2.x branch. Please clarify which branch we are patching in this issue.

Update: This patch applies to both 1.0 and 2.0. Can confirm that this rectifies the issue. RTBC.

lisa.rae’s picture

Status: Needs review » Reviewed & tested by the community
mglaman’s picture

+1 #6 made using this on Drupal 9 possible.

Leon Kessler made their first commit to this issue’s fork.

leon kessler’s picture

Version: 8.x-1.x-dev » 2.0.0-rc1

Added MR with patch from #6

mykola dolynskyi’s picture

@Leon Kessler thanks, waiting for this release

leon kessler’s picture

This project is currently not being actively maintained, it's been quite a while since any patches were merged in.
I've opened #3258564: Offering to co-maintain flysystem_s3 to help get issues like this one, into a release.

leon kessler’s picture

Status: Reviewed & tested by the community » Needs work

I now have commit access to this module, so will be working on merging this change in and creating a new release.

As this will break compatibility with Drupal 8.x, I've updated dependencies to be for 9.x.

Setting this back to needs work as it's not running through the test runner correctly.

damienmckenna’s picture

FWIW patch #6 resolved the problem for me.

leon kessler’s picture

Status: Needs work » Reviewed & tested by the community

Test runner issues are not actually related to this patch. So will set back to RTBC and focus on fixing tests in #3254472: Update tests to work with Drupal 9

leon kessler’s picture

StatusFileSize
new2.96 KB

Tests have now been fixed in 2.0.x. Re-posting patch from the MR (not sure why but the test runner doesn't seem to work correctly with gitlab MRs).

leon kessler’s picture

Version: 2.0.0-rc1 » 2.0.x-dev
leon kessler’s picture

I think the test runner issue is related to updating the composer.json file in the patch. I've posted on the drupal-infra slack channel (where I saw that someone else is having the same issue).

Here's the patch without the composer.json file change. If this passes, I suspect we can probably commit the previous patch (with composer.json) changes as the issue is that drupal infra doesn't like patches updating composer.json files.

  • Leon Kessler committed 079702c on 2.0.x
    Issue #3159928: uriScheme() method missing after update to Drupal 9
    
leon kessler’s picture

Status: Reviewed & tested by the community » Fixed

Merged in the gitlab MR that included the composer.json change. This appears to have run OK through the test runner https://www.drupal.org/pift-ci-job/2303413

Will tag a new release 2.0.0-rc2

nicolas bouteille’s picture

Status: Fixed » Active
StatusFileSize
new299.46 KB

Hello,
I am currently trying to upgrade my website to D9.
I have flysystem_s3 2.0.0-rc2 installed, yet when running drush cr I got the following error:

PHP Fatal error: Uncaught Error: Call to undefined method Drupal\Core\File\FileSystem::uriScheme() in /[…]web/modules/contrib/flysystem_s3/src/File/FlysystemS3FileSystem.php:63

I checked the source code, info.yml says:
version: '2.0.0-rc2'
project: 'flysystem_s3'
datestamp: 1643119088

class FlysystemS3FileSystem line 62:
public function chmod($uri, $mode = NULL) {
$scheme = parent::uriScheme($uri);

So it looks like the patch did not make it into the rc2 realease ?

nicolas bouteille’s picture

By the way, unfortunately patch does not seem to apply on D9.3.3 :(
EDIT : I guess the problem is not D9.3.3 but that I should probably downgrade to rc1 so that I can apply the patch...
EDIT 2 : nope, still no luck after downgrading to RC1... patch won't apply :(

leon kessler’s picture

Status: Active » Fixed

Sorry yes! I merged the MR but created the tag locally (without pulling the change), so yes it wasn't included. (Grrr this gitlab/patch workflow is not ideal).

Creating a new release 2.0.0-rc3 now to fix that.

nicolas bouteille’s picture

Great it works for me now :) thank you so much I am very lucky you actually fixed it right when I made the upgrade :)

Status: Fixed » Closed (fixed)

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