dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.87k stars 236 forks source link

headers_sent() returns true in php-cli mode #842

Open J-Cake opened 5 months ago

J-Cake commented 5 months ago

What happened?

I'm running (trying) to run NextCloud on FrankenPHP, which has been working for the most part, but when running the included Console script, I get a syntax error that there is content before the <?php section and should be removed. But there isn't.

Added by @withinboredom:

<?php

var_dump(headers_sent());

headers_sent() returns true in cli-mode.

Build Type

Official static build

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

Please see [phpinfo.php](https://nextcloud.jschneiderprojects.au/phpinfo.php)

Please let me know when you have viewed this, so I can take it down

Relevant log output

$ docker exec -it jcake-nextcloud-1 frankenphp php-cli /app/occ files:scan
An unhandled exception has been thrown:
Exception: Config file has leading content, please remove everything before "<?php" in config.php in /app/lib/private/Config.php:257
Stack trace:
#0 /app/lib/private/Config.php(71): OC\Config->readData()
#1 /app/lib/base.php(150): OC\Config->__construct('/app/config/')
#2 /app/lib/base.php(622): OC::initPaths()
#3 /app/lib/base.php(1181): OC::init()
#4 /app/console.php(48): require_once('/app/lib/base.p...')
#5 /app/occ(11): require_once('/app/console.ph...')
#6 {main}
withinboredom commented 5 months ago

But there isn't.

There may very well be hidden data that you cannot see in your text editor (non-printable characters, for example) or maybe whatever is reading the config is misinterpreting a BOM. Also, if there are any PHP errors in your config, it's possible it will detect this as input because PHP is outputting the error/warning.

withinboredom commented 5 months ago

This seems more like a nextcloud issue and not a frankenphp issue. Closing this.

J-Cake commented 5 months ago

Hi I forgot to link the thread from the Nextcloud support forums. There are no non-printable characters. I proved this using a hexdump.

withinboredom commented 5 months ago

Updated the context to include the actual bug

J-Cake commented 5 months ago

Updated the context to include the actual bug

Ah apologies... That would have been useful..