I'm trying to use Multiversion but I ran into a problem as soon as I enable it. I'm not sure if the fix is needed on Multiversion or Flysystem, but I thought I'd get your input.

Flysystem is working great and exactly as it should. However as soon as I enable Multiversion is when I get the problem. I try to add a node which has an image field. I browse for the image and after the progress indicator is complete the preview image never appears. I then try to save the node but I am unable to because the image is required and it wasn't loaded.

I'm fairly new to Drupal, but it seems that Multiversion is running a hook using a wrong service. Here is the error code that I get from the log:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "stream_wrapper.s3-files". Did you mean one of these: "stream_wrapper.public", "flysystem_stream_wrapper.s3-files"? in Drupal\Component\DependencyInjection\Container->get() (line 157 of /var/www/html/eldoradoshreveport.com/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php)

As I said, Flysystem was working fine before so I'm pretty sure Multiversion is causing this error. I just thought I'd get you opinion on where I should start looking for the cause of this error.

Thanx a lot for you help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chavab_1 created an issue. See original summary.

twistor’s picture

Title: Error when using with Multiversion » Incorrect stream wrapper handling.
Project: Flysystem » Multiversion
Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
Assigned: Unassigned » twistor
Category: Support request » Bug report

Yep, moving over to Multiversion. Will post patch shortly.

twistor’s picture

Sooo, this should fix the issue reported above, but the code is still incorrect.

multiversion_prepare_file_destination() should not take a StreamWrapperInterface as an argument. Stream wrappers shouldn't be instantiated by themselves except for the methods directly defined on StreamWrapperInterface.

twistor’s picture

Here's a quick version of a correct approach.

There are still some questions left undecided.

Status: Needs review » Needs work

twistor’s picture

There's a race condition in multiversion_prepare_file_destination().

I'm actually not sure why it exists at all. Here's a patch that uses file_prepare_directory().

twistor’s picture

Another curiosity, why does Drupal\multiversion\StreamWrapper\MigrateStream even exist? I haven't gone through all the code, but it looks like you're trying to define a sub-directory inside public files. This should not be a stream wrapper. MigrateStream::basePath() doesn't take into account a lot of things Drupal\Core\StreamWrapper\PublicStream does. It seems like the migrate:// stream wrapper should just be public://migrate.

I could be missing something here.

chavab_1’s picture

Thanx a lot @twistor!! That patch worked.

dixon_’s picture

@twistor Thanks for the work on this. These fixes makes sense I think. The reason for creating a new stream wrapper was just to make it easier to keep the same paths for the files, and just change the scheme. That way, we don't have to mess around with appending and removing migrate/ from the path all the time. But I'm happy to reconsider this, and just use the public stream wrapper.

However, I think the patch as it stands now looks like a good first step in the right direction. Maybe we can consider removing the migrate stream wrapper in a follow-up.

  • jeqq committed 19b9ea6 on 8.x-1.x authored by twistor
    Issue #2777899 by twistor, chavab_1, dixon_, jeqq: Incorrect stream...
jeqq’s picture

twistor’s picture

Assigned: twistor » Unassigned

That was quick!

Any thoughts on the todo I added in #8?

jeqq’s picture

chavab_1’s picture

FileSize
93.25 KB

Hey guys, I get the same error but now only after I run a deploy. I know the problem is no longer on Multiversion so I'm wondering if a similar fix is required on Relaxed Web Services as that's the type that I get from the Log report. I wasn't sure if I should open this issue on Relaxed's section since you guys are on top of it.

I really appreciate if you help me out.

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "stream_wrapper.s3-files". Did you mean one of these: "stream_wrapper.public", "flysystem_stream_wrapper.s3-files"? in Drupal\Component\DependencyInjection\Container->get() (line 157 of /var/www/html/eldoradoshreveport.com/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php)

jeqq’s picture

Status: Fixed » Closed (fixed)

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