31 Commits

Author SHA1 Message Date
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
20eb80fc9a
Modernize private property declarations in src/console 2022-05-17 20:34:55 +01:00
Dylan K. Taylor
856fd2a33b
fix PHPStan failures 2022-03-09 17:26:05 +00:00
Dylan K. Taylor
22bc3bc3f9
Replace disallowed operators in src/console/ 2022-01-20 16:49:04 +00:00
Dylan K. Taylor
8a94aa10a4
Merge branch 'stable' into next-minor 2021-12-14 00:34:54 +00:00
Dylan K. Taylor
e81bee3866
ConsoleReaderThread: disable opcache for console reader subprocess 2021-12-10 23:24:18 +00:00
Dylan K. Taylor
889d048ca3
Make use of Utils::assumeNotFalse() in a bunch of places
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).
2021-12-08 19:39:04 +00:00
Dylan K. Taylor
f239b077b9
Fixed PHPStan complaints 2021-11-30 00:36:38 +00:00
Dylan K. Taylor
6f8f460a6c
Partially revert "ConsoleReaderChildProcess: Commit suicide in more cases"
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).
2021-11-30 00:27:52 +00:00
Dylan K. Taylor
882df94bcb
ConsoleReaderThread: fixed zombie process leak 2021-11-29 23:45:10 +00:00
Dylan K. Taylor
2bb97d8904
Be quiet CS 2021-11-22 15:40:47 +00:00
Dylan K. Taylor
d3878b2d57
fixed spam 2021-11-22 15:37:33 +00:00
Dylan K. Taylor
cbe0f44c4f
ConsoleReaderChildProcess: Commit suicide in more cases
this makes it slightly less annoying to get rid of as an orphan process, though it still won't immediately die.
2021-11-22 14:58:45 +00:00
Dylan K. Taylor
4dc13ab3da
ConsoleReaderThread: strip control characters
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).
2021-11-02 15:11:23 +00:00
Dylan K. Taylor
b9d9b69bbe
ConsoleReaderThread: trim the string before returning it
it will have a newline at the end that was added by the subprocess when posting it to the main process.
2021-10-26 01:07:14 +01:00
Dylan K. Taylor
32588d79c8
ConsoleReaderThread: remove useless code 2021-09-10 13:54:42 +01:00
Dylan K. Taylor
a5b85e095a
Fixed some missing function imports
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.
2021-08-19 15:40:43 +01:00
Dylan K. Taylor
5da90b9530
Stop auto-translating strings when not asked
fixes #4371
2021-08-15 20:44:27 +01:00
Dylan K. Taylor
789a669395
Rename TranslationContainer -> Translatable 2021-08-15 16:17:46 +01:00
Dylan K. Taylor
b4c0ddd155
Use native union types for TranslationContainer|string 2021-08-10 15:17:26 +01:00
Dylan K. Taylor
de61417bb6
Simplify console subprocess require hack 2021-08-08 18:53:13 +01:00
Dylan K. Taylor
4c10dcaa53
ConsoleReaderThread: fixed UTF-8 paths getting corrupted on the way to the subprocess in some cases
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
2021-08-08 16:19:08 +01:00
Dylan K. Taylor
50b4ec0d20
Override timeout for the subprocess also 2021-08-03 18:50:36 +01:00
Dylan K. Taylor
16965fa742
ConsoleReaderThread: override default socket timeout for accept
otherwise, people can break the console reader by setting the default timeout to zero or some other small value.
2021-08-03 18:48:18 +01:00
Dylan K. Taylor
f9863acadc
Restart console reader subprocess if it dies
this can happen for a bunch of different reasons, which are all indistinguishable. This also fixes pmmp/PcntlSignalHandler#3.
2021-07-26 15:38:38 +01:00
Dylan T
c2c9132812 ConsoleReaderThread: say what actually happened when we fail to read commands 2021-07-26 15:17:24 +01:00
Dylan T
c7bb77e24a ConsoleReaderChildProcess: die voluntarily if connection to server process is closed
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
2021-07-26 15:07:47 +01:00
Dylan T
1246d1b7ef
Use a subprocess for reading lines from STDIN (#4332)
this FINALLY provides us with a way to deal with Windows without needing to forcibly terminate the entire server on shutdown.
2021-07-24 22:10:50 +01:00
Dylan K. Taylor
e14bad4ea6
Rename CommandReader and friends to ConsoleReader 2021-06-26 19:29:58 +01:00
Dylan K. Taylor
a70bd115f1
Moved console-specific stuff to its own namespace
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.
2021-06-26 19:24:46 +01:00