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

getallheaders function is undefined (sites using nginx) #40

Closed
skbly7 opened this issue May 26, 2016 · 1 comment
Closed

getallheaders function is undefined (sites using nginx) #40

skbly7 opened this issue May 26, 2016 · 1 comment
Assignees

Comments

@skbly7
Copy link
Contributor

skbly7 commented May 26, 2016

Title
getallheaders() function is not defined

Effected Users
The WordPress users having their site running on nginx + php-fpm instead of Apache.

Description

  • getallheaders() isn't available when Nginx + php-fpm setup exist.
  • No check on Amber code if the function exist or not
  • Instead define function from our side to be 100% sure.
if (!function_exists('getallheaders')) {
    function getallheaders() {
        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
    }
}

Place used
function validate_cache_referrer() in amber.php

Related links

Reference commit
22e0a39#diff-48a2bdcac7ee505e0aabaf11f1d698d8R794

Update:
Faced on
PHP Version 5.5.9-1ubuntu4.16
nginx version: nginx/1.8.1

@jlicht
Copy link
Collaborator

jlicht commented Sep 23, 2016

Merged pull request

@jlicht jlicht closed this as completed Sep 23, 2016
jlicht pushed a commit that referenced this issue Sep 24, 2016
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

No branches or pull requests

2 participants