Stage File Proxy not working with drimage

Created on 31 August 2020, over 4 years ago
Updated 5 December 2023, over 1 year ago

Problem/Motivation

The event subscriber of stage file proxy only supports files under the public file system. (There is a string check inside the event subscriber).

Steps to reproduce

With stage file proxy enabled drimage produces 500 errors if the image is not in the local file system.

Proposed resolution

A submodule drimage_stage_file_proxy can provide an own eventsubscriber and uses the FetchManager from stage file proxy to download the image. Would be a patch helpful or is an own contrib module maybe a better solution?

Thanks

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Christian.wiedemann

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France nanak Sarlat-la-CanΓ©da

    Hi, attached a patch inspired by the above MR, using a service decorator, available only if stage file proxy is installed, and works on the first request.

    Supports stage file proxy >= 2.0.3, as the decorated service was introduced in the version.

    About your remark in the previous comment "I'm guessing that this piece of code will need some extra checking for stage_file_proxy to fetch the original image before proceeding.": this is the case, the event subscriber fires and fetches the image before the drimage controller comes into play

  • Status changed to RTBC over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium mollux

    @nanak nice approach, this works as expected, and works on the first request.

    tested together with stage_file_proxy 2.1.2

  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium weseze

    A few remarks before we can get this in:

    1/ Do we need the "declare(strict_types = 1);"? I'd prefer not to do this.

    2/ Parts of the code require PHP8+. We still support Drupal9, which does not require PHP8. Can we rewrite the code in the patch to be compatible with PHP7? If not, we will need to also patch the info.yml and remove the D9.5 compatibility.

  • Status changed to Needs review over 1 year ago
  • πŸ‡«πŸ‡·France nanak Sarlat-la-CanΓ©da

    According to https://www.drupal.org/docs/getting-started/system-requirements/php-requ... β†’ , Drupal 9.5 is no longer marked as compatible with PHP 7, and supports PHP 8.0 & 8.1.

    Nevertheless, the attached patch should be compatible with PHP 7.4, and I removed the strict types check.

  • Status changed to Fixed over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium weseze

    Seems good to me. Haven't tested since I don't use stage_file_proxy module. I'm assuming it works ;)
    Will include this in the next release.

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    Are we sure omitting the class property in the service definition is supported in Drupal 9.3, which is the minimum supported version by this module? I know uppercase service names are only allowed since Drupal 9.5 β†’ , but I had no idea omitting the class property was even allowed. We should probably change the service ID and add the class property here.

  • πŸ‡§πŸ‡ͺBelgium weseze

    @DieterHolvoet: Have you got any D9.3 installations to test on? (I don't)
    Might be easier to just make a quick new release and up our minimum requirements to D9.5?

  • πŸ‡«πŸ‡·France nanak Sarlat-la-CanΓ©da

    I've been using class names as service id before 9.5 and it used to work, but I've made a mistake: this won't work with Drupal 9 at all due to the '@.inner' notation, which got introduced in Symfony 5.1, so only available from Drupal 10.0 onward.

    Attached, a patch using the syntax supported by both Drupal 9 and Drupal 10. I tried it on a Drupal 9.3 fresh install, and the service could properly be registered this time. Sorry for the mistake.

  • πŸ‡«πŸ‡·France nanak Sarlat-la-CanΓ©da

    Note that the above patch applies on top of #10

  • Status changed to Needs review over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    You forgot to update the service ID in DrimageServiceProvider, breaking any sites without Stage File Proxy installed. I attached a patch fixing the issue.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024