This function adds "base" format to a string. The given formats are inserted directly after any RESET code in the sequence.
An example of where this is needed is in the logger.
Without this change, the following code:
$logger->notice("I'm a " . TextFormat::RED . "special" . TextFormat::RESET . " cookie");
causes the "cookie" part of the message to show as grey, instead of the expected aqua for NOTICE level messages.
There are also many workarounds for this problem throughout the server, mostly in command outputs, being forced to use WHITE instead of RESET to avoid breaking the logger output.
this has a number of implications:
- Console command outputs are now (obviously) not logged. This is consistent with every other type of command sender, be it RCON, players, or anything else.
- The assumption that the console command sender must be able to see the logger output is now broken, since the command sender can receive output separately from the logs.
In the future, it might be desirable to send the console command output to stderr instead of stdout, so that stdout can be silenced while still allowing commands to be used.
closes#2543
There's no need to use an extra thread for this, since there's no concern of a socket getting stuck in a blocking read.
This is one less thing that can go wrong because of pthreads.
This happens if the main server process was forcibly killed, e.g. by the kill command on Linux, or taskkill/TaskManager on Windows.
Previously, the process would stick around as a zombie, which messed up terminals in some cases (e.g. git bash), though even having zombies with no side effects is bad enough.
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
This reverts commit cbe0f44c4f7bc3715acbf148f981bd93111c4c8f.
This achieves the same result as the reverted commit wrt. process in the
same manner (writing a keepalive into the socket and checking if it
failed to send). However, it does _not_ allow the process to die on
reaching pipe EOF, since this can cause many spams of subprocesses when
stdin is actually not a tty (e.g. in a Docker container).
this fixes a bug I encountered when accidentally pressing ctrl+a+d (which inserts a chr(1) character), because it made the server unable to find the command - but still reported an error containing what looked like a valid command (character isn't printable).
these weren't getting corrected since php-cs-fixer 3.0 due to a change in the default configuration for native_function_invocation. Since the builds are randomly choosing to use php-cs-fixer 2.19 at the moment, the consistency is a problem.
I was never able to reproduce this, but it appears that Windows breaks the character encoding of command parameters (and also unicode environment variables, even though UNICODE_ENVIRONMENT should be set in php-src) when the file path contains Unicode characters (such as Cyrillic).
We workaround this problem using base64, which is an abysmally shitty hack, but not worse than using a subprocess for ConsoleReader in the first place. PHP fucking sucks, and so does Windows.
closes#4353
this happens if the parent process is killed via SIGINT, because its stdin will be closed, interrupting a blocking read. This might also happen if the user pressed CTRL+D, so we don't die unless end of socket stream was also detected.
closes#4335
this stuff has different functionality than everything else in the
command namespace (specifically console handling), so it doesn't belong
in here.
I know that this will probably break some plugins, but I don't care,
because plugins shouldn't have been abusing ConsoleCommandSender in the
first place.