Skip to content

Warning: ini_set(): Headers already sent. #28273

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

Closed
xsuntel opened this issue Aug 26, 2018 · 2 comments
Closed

Warning: ini_set(): Headers already sent. #28273

xsuntel opened this issue Aug 26, 2018 · 2 comments

Comments

@xsuntel
Copy link

xsuntel commented Aug 26, 2018

Symfony version(s) affected: 4.1.3

Description

I have a problem about 500 error after I deployed a Symfony Application to Elastic Beanstalk.

Could you please give me an advice?

How to reproduce

Possible Solution

Additional context

[root@ip-xxx-xxx-xxx-xxx public]# vim index.php    

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
    Request::HEADER_X_FORWARDED_AWS_ELB;
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts(array('^(.+\.)?XXXX\.XXX$'));
}

[root@ip-xxx-xxx-xxx-xxx public]# php index.php

Notice: Uninitialized string offset: 0 in /var/app/current/vendor/symfony/http-foundation/Request.php on line 1988

Notice: Uninitialized string offset: 0 in /var/app/current/vendor/symfony/http-foundation/Request.php on line 1988

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/app/current/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php on line 52

Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /var/app/current/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php on line 53



private function normalizeAndFilterClientIps(array $clientIps, $ip)
{
    if (!$clientIps) {
        return array();
    }
    $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
    $firstTrustedIp = null;

    foreach ($clientIps as $key => $clientIp) {
        if (strpos($clientIp, '.')) {
            // Strip :port from IPv4 addresses. This is allowed in Forwarded
            // and may occur in X-Forwarded-For.
            $i = strpos($clientIp, ':');
            if ($i) {
                $clientIps[$key] = $clientIp = substr($clientIp, 0, $i);
            }
        // line 1988 ---->
        } elseif ('[' == $clientIp[0]) {
            // Strip brackets and :port from IPv6 addresses.
            $i = strpos($clientIp, ']', 1);
            $clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1);
        }

        if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
            unset($clientIps[$key]);

            continue;
        }

        if (IpUtils::checkIp($clientIp, self::$trustedProxies)) {
            unset($clientIps[$key]);

            // Fallback to this when the client IP falls into the range of trusted proxies
            if (null === $firstTrustedIp) {
                $firstTrustedIp = $clientIp;
            }
        }
    }

    // Now the IP chain contains only untrusted proxies and the client IP
    return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp);
}
@xabbuh
Copy link
Member

xabbuh commented Aug 26, 2018

Can you please check if this is the same as #28240 and thus fixed by #28241?

@xsuntel
Copy link
Author

xsuntel commented Aug 27, 2018

Thank you for your information. 👍
I think that It is the same issue about it. and I hope that a new version will be released as soon as possible because I can't deploy my application to Elastic beanstalk of AWS

@xsuntel xsuntel closed this as completed Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants