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
- Set up site in the way described
- Enable Stage File Proxy
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | stage_file_proxy-d7-undefined_array_key_extension-3405414-11.patch | 913 bytes | tibezh |
Issue fork stage_file_proxy-3405414
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
Comment #5
tibezh commentedWe need the same changes for the D7 module version.
I've added a patch for D7.
Comment #6
klausiLooks 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.
Comment #7
gregglesWould be good to declare php 7 in the info file if we're going to require it. Right?
Comment #8
klausiRight, that is a good idea! Setting back to needs review for that, the D10 change should be ready as is.
Comment #9
smustgrave commentedMerged into 2.1.x
Comment #10
smustgrave commentedFix
Comment #11
tibezh commentedHi 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.
Comment #13
smustgrave commentedDon'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...