mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Simplify console subprocess require hack
This commit is contained in:
@ -33,6 +33,7 @@ use function fopen;
|
|||||||
use function preg_replace;
|
use function preg_replace;
|
||||||
use function proc_open;
|
use function proc_open;
|
||||||
use function proc_terminate;
|
use function proc_terminate;
|
||||||
|
use function sprintf;
|
||||||
use function stream_select;
|
use function stream_select;
|
||||||
use function stream_socket_accept;
|
use function stream_socket_accept;
|
||||||
use function stream_socket_get_name;
|
use function stream_socket_get_name;
|
||||||
@ -87,18 +88,14 @@ final class ConsoleReaderThread extends Thread{
|
|||||||
$address = stream_socket_get_name($server, false);
|
$address = stream_socket_get_name($server, false);
|
||||||
if($address === false) throw new AssumptionFailedError("stream_socket_get_name() shouldn't return false here");
|
if($address === false) throw new AssumptionFailedError("stream_socket_get_name() shouldn't return false here");
|
||||||
|
|
||||||
$subEnv = $_ENV;
|
|
||||||
//Windows sucks, and likes to corrupt UTF-8 file paths when they travel to the subprocess, so we base64 encode
|
//Windows sucks, and likes to corrupt UTF-8 file paths when they travel to the subprocess, so we base64 encode
|
||||||
//the path to avoid the problem. This is an abysmally shitty hack, but here we are :(
|
//the path to avoid the problem. This is an abysmally shitty hack, but here we are :(
|
||||||
$subEnv["PMConsoleReaderChildProcessFile"] = base64_encode(Path::join(__DIR__, 'ConsoleReaderChildProcess.php'));
|
|
||||||
$sub = proc_open(
|
$sub = proc_open(
|
||||||
[PHP_BINARY, '-r', 'require base64_decode($_ENV["PMConsoleReaderChildProcessFile"], true);', $address],
|
[PHP_BINARY, '-r', sprintf('require base64_decode("%s", true);', base64_encode(Path::join(__DIR__, 'ConsoleReaderChildProcess.php'))), $address],
|
||||||
[
|
[
|
||||||
2 => fopen("php://stderr", "w"),
|
2 => fopen("php://stderr", "w"),
|
||||||
],
|
],
|
||||||
$pipes,
|
$pipes
|
||||||
null,
|
|
||||||
$subEnv
|
|
||||||
);
|
);
|
||||||
if($sub === false){
|
if($sub === false){
|
||||||
throw new AssumptionFailedError("Something has gone horribly wrong");
|
throw new AssumptionFailedError("Something has gone horribly wrong");
|
||||||
|
Reference in New Issue
Block a user