mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
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:
@@ -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");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ abstract class CLI
|
||||
$msg = (self::$overwriteLast && CLI_HAS_E ? "\e[1G\e[0K" : "\n") . $msg;
|
||||
self::$overwriteLast = $tmpRow;
|
||||
|
||||
echo $msg;
|
||||
fwrite($lvl == self::LOG_ERROR ? STDERR : STDOUT, $msg);
|
||||
|
||||
if (self::$logHandle) // remove control sequences from log
|
||||
fwrite(self::$logHandle, self::purgeEscapes($msg));
|
||||
@@ -412,7 +412,7 @@ abstract class CLI
|
||||
$charBuff = '';
|
||||
|
||||
if ($desc)
|
||||
echo "\n".$desc.": ";
|
||||
fwrite(STDOUT, "\n".$desc.": ");
|
||||
|
||||
while (true) {
|
||||
if (feof(STDIN))
|
||||
@@ -433,7 +433,7 @@ abstract class CLI
|
||||
{
|
||||
if (count($ordinals) == 1)
|
||||
{
|
||||
echo chr(self::CHR_BELL);
|
||||
fwrite(STDOUT, chr(self::CHR_BELL));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -455,7 +455,7 @@ abstract class CLI
|
||||
|
||||
$charBuff = mb_substr($charBuff, 0, -1);
|
||||
if (!$isHidden && self::$hasReadline)
|
||||
echo chr(self::CHR_BACK)." ".chr(self::CHR_BACK);
|
||||
fwrite(STDOUT, chr(self::CHR_BACK)." ".chr(self::CHR_BACK));
|
||||
}
|
||||
// standalone \n or \r
|
||||
else if ($keyId == self::CHR_LF || $keyId == self::CHR_CR)
|
||||
@@ -467,7 +467,7 @@ abstract class CLI
|
||||
{
|
||||
$charBuff .= $char;
|
||||
if (!$isHidden && self::$hasReadline)
|
||||
echo $char;
|
||||
fwrite(STDOUT, $char);
|
||||
|
||||
if ($singleChar && self::$hasReadline)
|
||||
{
|
||||
@@ -479,7 +479,7 @@ abstract class CLI
|
||||
}
|
||||
}
|
||||
|
||||
echo chr(self::CHR_BELL);
|
||||
fwrite(STDOUT, chr(self::CHR_BELL));
|
||||
|
||||
foreach ($userInput as $ui)
|
||||
if (strlen($ui))
|
||||
|
||||
@@ -26,6 +26,7 @@ if (CLISetup::getOpt('delete')) // generated with TEMPOR
|
||||
|
||||
CLISetup::runInitial();
|
||||
|
||||
die("\n");
|
||||
fwrite(STDOUT, "\n");
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user