PHP/Compat

* avoid using "echo" to write to CLI as php mistakes it for sent headers (see php-src #12303)
 * as we are using fwrite now, errors are written to STDERR instead of STDOUT
 * fixes an issue where reloading the config would cause "ini_set(): Session ini settings cannot be changed after headers have already been sent" to be spammed
This commit is contained in:
Sarjuuk 2024-07-30 19:51:57 +02:00
parent b5c2f7a296
commit 1b2b773663
3 changed files with 10 additions and 9 deletions

View file

@ -135,7 +135,7 @@ set_exception_handler(function ($e)
);
if (CLI)
echo "\nException - ".$e->getMessage()."\n ".$e->getFile(). '('.$e->getLine().")\n".$e->getTraceAsString()."\n\n";
fwrite(STDERR, "\nException - ".$e->getMessage()."\n ".$e->getFile(). '('.$e->getLine().")\n".$e->getTraceAsString()."\n\n");
else
{
Util::addNote('Exception - '.$e->getMessage().' @ '.$e->getFile(). ':'.$e->getLine()."\n".$e->getTraceAsString(), U_GROUP_EMPLOYEE, CLI::LOG_ERROR);
@ -154,7 +154,7 @@ register_shutdown_function(function()
);
if (CLI || User::isInGroup(U_GROUP_EMPLOYEE))
echo "\nFatal Error - ".$e['message'].' @ '.$e['file']. ':'.$e['line']."\n\n";
fwrite(STDERR, "\nFatal Error - ".$e['message'].' @ '.$e['file']. ':'.$e['line']."\n\n");
}
});