Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve getScheme on Zend_Controller_Request_Http #1872

Merged
merged 2 commits into from Feb 16, 2022

Conversation

mmenozzi
Copy link
Contributor

Description (*)

Some web servers (for example the local web server of the Symfony CLI) puts the value On (and not on) in the $_SERVER['HTTPS'] super global.

With this PR the Zend_Controller_Request_Http::getScheme properly returns the HTTPS scheme in such situations.

Manual testing scenarios (*)

  1. Install a clean copy of OpenMage as usual
  2. Install Symfony CLI and its SSL certificates
  3. Start the Symfony CLI local web server with symfony server:start
  4. Configure OpenMage to use the https://127.0.0.1:8000/ base URL for both secure and unsecure
  5. Try to open the home page at https://127.0.0.1:8000/
  6. Without this PR you'll get "Too many redirects" error, with this PR you'll properly get the home page

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

elidrissidev
elidrissidev previously approved these changes Nov 4, 2021
sreichel
sreichel previously approved these changes Jan 12, 2022
ADDISON74
ADDISON74 previously approved these changes Jan 12, 2022
Copy link
Collaborator

@luigifab luigifab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With PHP 8.1, if $this->getServer('HTTPS') return null, it will crash.
strtolower(null): PHP Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated

Not sure if this case can happen.

Copy link
Member

@Flyingmana Flyingmana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strtolower requires a string, but we could get a null here as of

/**
* Retrieve a member of the $_SERVER superglobal
*
* If no $key is passed, returns the entire $_SERVER array.
*
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*/
public function getServer($key = null, $default = null)
{
if (null === $key) {
return $_SERVER;
}
return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
}

@Flyingmana Flyingmana merged commit a1b01fa into OpenMage:1.9.4.x Feb 16, 2022
@github-actions
Copy link

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
7 runs  ±0  5 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit a1b01fa. ± Comparison against base commit 8b9bfae.

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.

None yet

6 participants