Skip to content

Do not fail on undefined request scheme#8

Open
OndraM wants to merge 1 commit into
DantSu:masterfrom
OndraM:patch-1
Open

Do not fail on undefined request scheme#8
OndraM wants to merge 1 commit into
DantSu:masterfrom
OndraM:patch-1

Conversation

@OndraM

@OndraM OndraM commented Sep 25, 2023

Copy link
Copy Markdown

When using local PHP server, the 'REQUEST_SCHEME' is empty for me, causing the script to fail:

Warning: Undefined array key "REQUEST_SCHEME"

This will fallback to 'http' when REQUEST_SCHEME is set.

@roelofjan-elsinga

Copy link
Copy Markdown
Contributor

This referrer currently breaks my installation as I'm only using this package with a local CLI script. This PR would fix my problem.

@metzg

metzg commented Nov 18, 2023

Copy link
Copy Markdown

In my case (CLI script), the following keys were missing: REQUEST_SCHEME, HTTP_HOST, REQUEST_URI. Would you consider adding those two other keys in your patch?

A workaround I found without this patch was to set those values manually before calling getImage, but it's not ideal:

$_SERVER['REQUEST_SCHEME'] = $_SERVER['REQUEST_SCHEME'] ?? 'https';
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_HOST'] ?? 'example.com';
$_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI'] ??  '';

// ...

$foo->getImage();

Thanks,

@DantSu

DantSu commented Nov 18, 2023

Copy link
Copy Markdown
Owner

Yes, this workaround is a better way than the patch, because you can set custom value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants