facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.19k stars 3k forks source link

Headers_sent() behavior does not match zend in CLI #2220

Closed drobertduke closed 10 years ago

drobertduke commented 10 years ago
<?php
class Headers_Test extends PHPUnit_Framework_TestCase
{
    public function test_headers() {
        var_dump(headers_sent());
    }
}
$ phpunit test/php/headers.php
PHPUnit 4.0.12 by Sebastian Bergmann.

Configuration read from /box/www/dduke/phpunit.xml

.bool(true)

Time: 87 ms, Memory: 9.00Mb

OK (1 test, 0 assertions)
$ hhvm vendor/phpunit/phpunit/phpunit test/php/headers.php
PHPUnit 4.0.12 by Sebastian Bergmann.

Configuration read from /box/www/dduke/phpunit.xml

.bool(false)

Time: 77 ms, Memory: 6.78Mb

OK (1 test, 0 assertions)
scannell commented 10 years ago

Thanks for reporting this. Feel free to submit a PR if you (or someone else reading this) gets to this before we do.

jeffchan commented 10 years ago

I can confirm this is breaking 2 tests on Kohana. Kohana_CookieTest::test_set and Kohana_CookieTest::test_get

fredemmott commented 10 years ago

Interestingly enough, if you just do this:

<?php
var_dump(headers_sent());

... without using PHPUnit, php5 also says false.

fredemmott commented 10 years ago

Two repros without PHPUnit:

<?php
echo "Foo\n";
var_dump(headers_sent()); // there's already been output
<?php
var_dump(headers_sent()); // false
var_dump(headers_sent()); //true
fredemmott commented 10 years ago

Fix up for review internally (FB: D1325097)