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

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

Open
J-Cake opened this issue Jun 3, 2024 · 5 comments
Open

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

J-Cake opened this issue Jun 3, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@J-Cake
Copy link

J-Cake commented Jun 3, 2024

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}
@J-Cake J-Cake added the bug Something isn't working label Jun 3, 2024
@withinboredom
Copy link
Collaborator

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
Copy link
Collaborator

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

@J-Cake
Copy link
Author

J-Cake commented Jun 3, 2024

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 withinboredom reopened this Jun 3, 2024
@withinboredom
Copy link
Collaborator

Updated the context to include the actual bug

@withinboredom withinboredom changed the title Misinterpretation of PHP script headers_sent() returns true in php-cli mode Jun 3, 2024
@J-Cake
Copy link
Author

J-Cake commented Jun 3, 2024

Updated the context to include the actual bug

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants