Problem/Motivation

We're dealing with a custom stream wrapper that provides externally sourced files which are stored without a file extension. Upon trying to use Stage File Proxy on this site, the following error message is emitted:

Warning: Undefined array key "extension" in Drupal\stage_file_proxy\EventSubscriber\StageFileProxySubscriber->checkFileOrigin() (line 127 of modules/contrib/stage_file_proxy/src/EventSubscriber/StageFileProxySubscriber.php).

This warning could be alleviated with a small check to default the extension to an empty string, probably without affecting the rest of the module's existing behaviour.

Steps to reproduce

  1. Set up site in the way described
  2. Enable Stage File Proxy
  3. Navigate to a page which shows some of these images

Proposed resolution

$extension = pathinfo($request_path)['extension'] ?? '';

Remaining tasks

Implement change and test.

User interface changes

None.

API changes

None.

Data model changes

None.

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

geoffreyr created an issue. See original summary.

tibezh changed the visibility of the branch 3405414-provide-fallbacks-for to hidden.

tibezh changed the visibility of the branch 3405414-provide-fallbacks-for to active.

tibezh’s picture

Assigned: geoffreyr » Unassigned
Status: Active » Needs review
StatusFileSize
new559 bytes

We need the same changes for the D7 module version.
I've added a patch for D7.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me! I'm RTBC'ing the Drupal 7 version. The "??" operator only exists in PHP 7, but I think that is ok, not sure how many Drupal 7 sites on PHP 5 are still out there.

greggles’s picture

Would be good to declare php 7 in the info file if we're going to require it. Right?

klausi’s picture

Status: Reviewed & tested by the community » Needs review

Right, that is a good idea! Setting back to needs review for that, the D10 change should be ready as is.

smustgrave’s picture

Merged into 2.1.x

smustgrave’s picture

Status: Needs review » Fixed

Fix

tibezh’s picture

Version: 2.0.x-dev » 7.x-1.x-dev
Status: Fixed » Needs review
StatusFileSize
new913 bytes

Hi All there,

I need to reopen the issue because we have the same troubles for D7 module version.

Thanx @greggles for the notice about the PHP version.

@smustgrave, could you check my new patch for D7 module version, please?
It should be good now.

  • smustgrave committed 5c542199 on 7.x-1.x authored by tibezh
    Issue #3405414 by tibezh, geoffreyr, klausi, smustgrave, greggles:...
smustgrave’s picture

Status: Needs review » Fixed

Don't mind committing to D7 branch but really the D7 branch is all but done.

https://git.drupalcode.org/project/stage_file_proxy/-/commit/5c54219976c...

Status: Fixed » Closed (fixed)

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