diff --git a/config/patches/frankenphp-1757.patch b/config/patches/frankenphp-1757.patch deleted file mode 100644 index 3d80c9e..0000000 --- a/config/patches/frankenphp-1757.patch +++ /dev/null @@ -1,617 +0,0 @@ -diff --git a/caddy/php-cli.go b/caddy/php-cli.go -index 4e76ff147a..53b754a59f 100644 ---- a/caddy/php-cli.go -+++ b/caddy/php-cli.go -@@ -1,9 +1,9 @@ - package caddy - - import ( -- "errors" - "os" - "path/filepath" -+ "strings" - - caddycmd "github.com/caddyserver/caddy/v2/cmd" - "github.com/dunglas/frankenphp" -@@ -26,23 +26,16 @@ Executes a PHP script similarly to the CLI SAPI.`, - } - - func cmdPHPCLI(fs caddycmd.Flags) (int, error) { -- args := os.Args[2:] -- if len(args) < 1 { -- return 1, errors.New("the path to the PHP script is required") -- } -+ // php's cli sapi expects the 0th arg to be the program itself, only filter out 'php-cli' arg -+ args := append([]string{os.Args[0]}, os.Args[2:]...) - -- if frankenphp.EmbeddedAppPath != "" { -- if _, err := os.Stat(args[0]); err != nil { -- args[0] = filepath.Join(frankenphp.EmbeddedAppPath, args[0]) -+ if frankenphp.EmbeddedAppPath != "" && len(args) > 1 && !strings.HasPrefix(args[1], "-") && strings.HasSuffix(args[1], ".php") { -+ if _, err := os.Stat(args[1]); err != nil { -+ args[1] = filepath.Join(frankenphp.EmbeddedAppPath, args[1]) - } - } - -- var status int -- if len(args) >= 2 && args[0] == "-r" { -- status = frankenphp.ExecutePHPCode(args[1]) -- } else { -- status = frankenphp.ExecuteScriptCLI(args[0], args) -- } -+ status := frankenphp.ExecuteScriptCLI(args[0], args) - - os.Exit(status) - -diff --git a/cgo.go b/cgo.go -index 8dc2609007..653329c956 100644 ---- a/cgo.go -+++ b/cgo.go -@@ -6,6 +6,6 @@ package frankenphp - // #cgo unix LDFLAGS: -lphp -lm -lutil - // #cgo linux LDFLAGS: -ldl -lresolv - // #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl --// #cgo windows CFLAGS: -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -D_MBCS -D_USE_MATH_DEFINES -DNDebug -DNDEBUG -DZEND_DEBUG=0 -DZTS=1 -DFD_SETSIZE=256 -+// #cgo windows CFLAGS: -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -D_MBCS -D_USE_MATH_DEFINES -DNDebug -DNDEBUG -DZEND_DEBUG=0 -DZTS=1 -DFD_SETSIZE=256 -DENABLE_INTSAFE_SIGNED_FUNCTIONS - // #cgo windows LDFLAGS: -lpthreadVC3 - import "C" -diff --git a/cli.go b/cli.go -index 96821a2392..a96153a14a 100644 ---- a/cli.go -+++ b/cli.go -@@ -18,12 +18,3 @@ func ExecuteScriptCLI(script string, args []string) int { - - return int(C.frankenphp_execute_script_cli(cScript, argc, (**C.char)(unsafe.Pointer(&argv[0])), false)) - } -- --func ExecutePHPCode(phpCode string) int { -- // Ensure extensions are registered before CLI execution -- registerExtensions() -- -- cCode := C.CString(phpCode) -- defer C.free(unsafe.Pointer(cCode)) -- return int(C.frankenphp_execute_script_cli(cCode, 0, nil, true)) --} -diff --git a/cli_test.go b/cli_test.go -index 964bb49907..5a07dd8d2c 100644 ---- a/cli_test.go -+++ b/cli_test.go -@@ -46,6 +46,34 @@ func TestExecuteCLICode(t *testing.T) { - assert.Equal(t, stdoutStderrStr, `Hello World`) - } - -+// `-i` (and any other invocation without a script) is only supported since PHP -+// 8.6, where the real CLI SAPI is reused. older versions must fail cleanly. -+func TestExecuteCLIPHPInfo(t *testing.T) { -+ if _, err := os.Stat("internal/testcli/testcli"); err != nil { -+ t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`") -+ } -+ -+ cmd := exec.Command("internal/testcli/testcli", "-i") -+ stdoutStderr, err := cmd.CombinedOutput() -+ stdoutStderrStr := string(stdoutStderr) -+ -+ if frankenphp.Version().VersionID < 80600 { -+ assert.Error(t, err) -+ -+ var exitError *exec.ExitError -+ if errors.As(err, &exitError) { -+ assert.Equal(t, 1, exitError.ExitCode()) -+ } -+ -+ assert.Contains(t, stdoutStderrStr, "this functionality is not available in frankenphp php-cli") -+ -+ return -+ } -+ -+ assert.NoError(t, err, "output: %s", stdoutStderrStr) -+ assert.Contains(t, stdoutStderrStr, "PHP Version => "+frankenphp.Version().Version) -+} -+ - // Regression test for https://github.com/php/frankenphp/issues/1902. A - // long-running CLI script that installs pcntl_signal handlers must - // receive its own signals reliably -@@ -73,5 +101,5 @@ func ExampleExecuteScriptCLI() { - os.Exit(1) - } - -- os.Exit(frankenphp.ExecuteScriptCLI(os.Args[1], os.Args)) -+ os.Exit(frankenphp.ExecuteScriptCLI(os.Args[0], os.Args)) - } -diff --git a/emulate_php_cli.c b/emulate_php_cli.c -new file mode 100644 -index 0000000000..f33f360359 ---- /dev/null -+++ b/emulate_php_cli.c -@@ -0,0 +1,191 @@ -+#include "emulate_php_cli.h" -+#include "frankenphp.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#ifdef PHP_WIN32 -+#include -+#else -+#include -+#endif -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#ifndef ZEND_WIN32 -+#include -+#endif -+#if defined(__linux__) -+#include -+#elif defined(__FreeBSD__) || defined(__OpenBSD__) -+#include -+#endif -+ -+cli_exec_args_t *cli_args; -+ -+static void register_server_variable_filtered(const char *key, char **val, -+ size_t *val_len, -+ zval *track_vars_array) { -+ if (sapi_module.input_filter(PARSE_SERVER, key, val, *val_len, val_len)) { -+ php_register_variable_safe(key, *val, *val_len, track_vars_array); -+ } -+} -+ -+/* -+ * CLI code is adapted from -+ * https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c Copyright (c) -+ * The PHP Group Licensed under The PHP License Original uthors: Edin Kadribasic -+ * , Marcus Boerger and Johannes Schlueter -+ * Parts based on CGI SAPI Module by Rasmus Lerdorf, Stig -+ * Bakken and Zeev Suraski -+ */ -+static void cli_register_file_handles(bool no_close) /* {{{ */ -+{ -+ php_stream *s_in, *s_out, *s_err; -+ php_stream_context *sc_in = NULL, *sc_out = NULL, *sc_err = NULL; -+ zend_constant ic, oc, ec; -+ -+ s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in); -+ s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); -+ s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); -+ -+ if (s_in == NULL || s_out == NULL || s_err == NULL) { -+ if (s_in) -+ php_stream_close(s_in); -+ if (s_out) -+ php_stream_close(s_out); -+ if (s_err) -+ php_stream_close(s_err); -+ return; -+ } -+ -+ if (no_close) { -+ s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE; -+ s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE; -+ s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE; -+ } -+ -+ /*s_in_process = s_in;*/ -+ -+ php_stream_to_zval(s_in, &ic.value); -+ php_stream_to_zval(s_out, &oc.value); -+ php_stream_to_zval(s_err, &ec.value); -+ -+ ZEND_CONSTANT_SET_FLAGS(&ic, CONST_CS, 0); -+ ic.name = zend_string_init_interned("STDIN", sizeof("STDIN") - 1, 0); -+ zend_register_constant(&ic); -+ -+ ZEND_CONSTANT_SET_FLAGS(&oc, CONST_CS, 0); -+ oc.name = zend_string_init_interned("STDOUT", sizeof("STDOUT") - 1, 0); -+ zend_register_constant(&oc); -+ -+ ZEND_CONSTANT_SET_FLAGS(&ec, CONST_CS, 0); -+ ec.name = zend_string_init_interned("STDERR", sizeof("STDERR") - 1, 0); -+ zend_register_constant(&ec); -+} -+/* }}} */ -+ -+static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */ -+{ -+ size_t len = strlen(cli_args->script); -+ char *docroot = ""; -+ -+ /* -+ * In CGI mode, we consider the environment to be a part of the server -+ * variables -+ */ -+ php_import_environment_variables(track_vars_array); -+ -+ /* Build the special-case PHP_SELF variable for the CLI version */ -+ register_server_variable_filtered("PHP_SELF", &cli_args->script, &len, -+ track_vars_array); -+ register_server_variable_filtered("SCRIPT_NAME", &cli_args->script, &len, -+ track_vars_array); -+ -+ /* filenames are empty for stdin */ -+ register_server_variable_filtered("SCRIPT_FILENAME", &cli_args->script, &len, -+ track_vars_array); -+ register_server_variable_filtered("PATH_TRANSLATED", &cli_args->script, &len, -+ track_vars_array); -+ -+ /* just make it available */ -+ len = 0U; -+ register_server_variable_filtered("DOCUMENT_ROOT", &docroot, &len, -+ track_vars_array); -+} -+/* }}} */ -+ -+void *emulate_script_cli(void *arg) { -+ void *exit_status; -+ cli_exec_args_t *args = arg; -+ cli_args = args; -+ -+ /* Parse argv to detect -r (eval mode) and find the script path */ -+ bool eval = false; -+ char *script = NULL; -+ for (int i = 1; i < args->argc; i++) { -+ if (strcmp(args->argv[i], "-r") == 0 && i + 1 < args->argc) { -+ eval = true; -+ script = args->argv[i + 1]; -+ break; -+ } else if (args->argv[i][0] != '-') { -+ script = args->argv[i]; -+ break; -+ } -+ } -+ -+ if (script == NULL) { -+ fprintf(stderr, "this functionality is not available in frankenphp php-cli " -+ "with a php version lower than 8.6\n"); -+ return (void *)(intptr_t)1; -+ } -+ -+ /* Update cli_args->script so sapi_cli_register_variables uses the right path -+ */ -+ cli_args->script = script; -+ -+ /* -+ * The SAPI name "cli" is hardcoded into too many programs... let's usurp it. -+ */ -+ php_embed_module.name = "cli"; -+ php_embed_module.pretty_name = "PHP CLI embedded in FrankenPHP"; -+ php_embed_module.register_server_variables = sapi_cli_register_variables; -+ -+ php_embed_init(cli_args->argc, cli_args->argv); -+ -+ cli_register_file_handles(false); -+ zend_first_try { -+ if (eval) { -+ /* evaluate script as literal PHP code (php-cli -r "...") */ -+ zend_eval_string_ex(script, NULL, "Command line code", 1); -+ } else { -+ zend_file_handle file_handle; -+ zend_stream_init_filename(&file_handle, script); -+ -+ CG(skip_shebang) = 1; -+ php_execute_script(&file_handle); -+ } -+ } -+ zend_end_try(); -+ -+ exit_status = (void *)(intptr_t)EG(exit_status); -+ -+ php_embed_shutdown(); -+ -+ return exit_status; -+} -diff --git a/emulate_php_cli.h b/emulate_php_cli.h -new file mode 100644 -index 0000000000..9179ceb7e7 ---- /dev/null -+++ b/emulate_php_cli.h -@@ -0,0 +1,15 @@ -+#ifndef _EMULATE_PHP_CLI_H -+#define _EMULATE_PHP_CLI_H -+ -+#include -+ -+typedef struct { -+ char *script; -+ int argc; -+ char **argv; -+ bool eval; -+} cli_exec_args_t; -+extern cli_exec_args_t *cli_args; -+void *emulate_script_cli(void *arg); -+ -+#endif -diff --git a/frankenphp.c b/frankenphp.c -index a47b6d80a7..91911df0e2 100644 ---- a/frankenphp.c -+++ b/frankenphp.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -44,6 +45,11 @@ - #include - #endif - -+#if PHP_VERSION_ID >= 80600 -+#include -+#endif -+#include "emulate_php_cli.h" -+ - #include "_cgo_export.h" - #include "frankenphp_arginfo.h" - #ifdef FRANKENPHP_TEST -@@ -1359,15 +1365,6 @@ void frankenphp_register_variable_safe(char *key, char *val, size_t val_len, - } - } - --static inline void register_server_variable_filtered(const char *key, -- char **val, -- size_t *val_len, -- zval *track_vars_array) { -- if (sapi_module.input_filter(PARSE_SERVER, key, val, *val_len, val_len)) { -- php_register_variable_safe(key, *val, *val_len, track_vars_array); -- } --} -- - static void frankenphp_register_variables(zval *track_vars_array) { - /* https://www.php.net/manual/en/reserved.variables.server.php */ - -@@ -1749,101 +1746,10 @@ bool frankenphp_new_php_thread(uintptr_t thread_index) { - return true; - } - --/* Use global variables to store CLI arguments to prevent useless allocations */ --static char *cli_script; --static int cli_argc; --static char **cli_argv; -- --/* -- * CLI code is adapted from -- * https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c Copyright (c) -- * The PHP Group Licensed under The PHP License Original uthors: Edin Kadribasic -- * , Marcus Boerger and Johannes Schlueter -- * Parts based on CGI SAPI Module by Rasmus Lerdorf, Stig -- * Bakken and Zeev Suraski -- */ --static void cli_register_file_handles(void) { -- php_stream *s_in, *s_out, *s_err; -- php_stream_context *sc_in = NULL, *sc_out = NULL, *sc_err = NULL; -- zend_constant ic, oc, ec; -- -- s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in); -- s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); -- s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); -- -- /* Release stream resources, but don't free the underlying handles. Othewrise, -- * extensions which write to stderr or company during mshutdown/gshutdown -- * won't have the expected functionality. -- */ -- if (s_in) -- s_in->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE; -- if (s_out) -- s_out->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE; -- if (s_err) -- s_err->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE; -- -- if (s_in == NULL || s_out == NULL || s_err == NULL) { -- if (s_in) -- php_stream_close(s_in); -- if (s_out) -- php_stream_close(s_out); -- if (s_err) -- php_stream_close(s_err); -- return; -- } -- -- /*s_in_process = s_in;*/ -- -- php_stream_to_zval(s_in, &ic.value); -- php_stream_to_zval(s_out, &oc.value); -- php_stream_to_zval(s_err, &ec.value); -- -- ZEND_CONSTANT_SET_FLAGS(&ic, CONST_CS, 0); -- ic.name = zend_string_init_interned("STDIN", sizeof("STDIN") - 1, 0); -- zend_register_constant(&ic); -- -- ZEND_CONSTANT_SET_FLAGS(&oc, CONST_CS, 0); -- oc.name = zend_string_init_interned("STDOUT", sizeof("STDOUT") - 1, 0); -- zend_register_constant(&oc); -- -- ZEND_CONSTANT_SET_FLAGS(&ec, CONST_CS, 0); -- ec.name = zend_string_init_interned("STDERR", sizeof("STDERR") - 1, 0); -- zend_register_constant(&ec); --} -- --static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */ --{ -- size_t len = strlen(cli_script); -- char *docroot = ""; -- -- /* -- * In CGI mode, we consider the environment to be a part of the server -- * variables -- */ -- php_import_environment_variables(track_vars_array); -- -- /* Build the special-case PHP_SELF variable for the CLI version */ -- register_server_variable_filtered("PHP_SELF", &cli_script, &len, -- track_vars_array); -- register_server_variable_filtered("SCRIPT_NAME", &cli_script, &len, -- track_vars_array); -- -- /* filenames are empty for stdin */ -- register_server_variable_filtered("SCRIPT_FILENAME", &cli_script, &len, -- track_vars_array); -- register_server_variable_filtered("PATH_TRANSLATED", &cli_script, &len, -- track_vars_array); -- -- /* just make it available */ -- len = 0U; -- register_server_variable_filtered("DOCUMENT_ROOT", &docroot, &len, -- track_vars_array); --} - /* }}} */ - - static void *execute_script_cli(void *arg) { -- void *exit_status; -- bool eval = (bool)arg; -+ cli_exec_args_t *args = (cli_exec_args_t *)arg; - - #ifndef PHP_WIN32 - sigset_t cli_signals; -@@ -1851,39 +1757,11 @@ static void *execute_script_cli(void *arg) { - pthread_sigmask(SIG_UNBLOCK, &cli_signals, NULL); - #endif - -- /* -- * The SAPI name "cli" is hardcoded into too many programs... let's usurp it. -- */ -- php_embed_module.name = "cli"; -- php_embed_module.pretty_name = "PHP CLI embedded in FrankenPHP"; -- php_embed_module.register_server_variables = sapi_cli_register_variables; -- -- php_embed_init(cli_argc, cli_argv); -- -- // php_embed_init() forces SG(headers_sent) = 1 and no_headers = 1 -- SG(headers_sent) = 0; -- SG(request_info).no_headers = 0; -- -- cli_register_file_handles(); -- zend_first_try { -- if (eval) { -- /* evaluate the cli_script as literal PHP code (php-cli -r "...") */ -- zend_eval_string_ex(cli_script, NULL, "Command line code", 1); -- } else { -- zend_file_handle file_handle; -- zend_stream_init_filename(&file_handle, cli_script); -- -- CG(skip_shebang) = 1; -- php_execute_script(&file_handle); -- } -- } -- zend_end_try(); -- -- exit_status = (void *)(intptr_t)EG(exit_status); -- -- php_embed_shutdown(); -- -- return exit_status; -+#if PHP_VERSION_ID >= 80600 -+ return (void *)(intptr_t)do_php_cli(args->argc, args->argv); -+#else -+ return (void *)(intptr_t)emulate_script_cli(args); -+#endif - } - - int frankenphp_execute_script_cli(char *script, int argc, char **argv, -@@ -1892,15 +1770,14 @@ int frankenphp_execute_script_cli(char *script, int argc, char **argv, - int err; - void *exit_status; - -- cli_script = script; -- cli_argc = argc; -- cli_argv = argv; -+ cli_exec_args_t args = { -+ .script = script, .argc = argc, .argv = argv, .eval = eval}; - - /* - * Start the script in a dedicated thread to prevent conflicts between Go and - * PHP signal handlers - */ -- err = pthread_create(&thread, NULL, execute_script_cli, (void *)eval); -+ err = pthread_create(&thread, NULL, execute_script_cli, &args); - if (err != 0) { - return err; - } -diff --git a/frankenphp.h b/frankenphp.h -index db32a82fe0..99ac0ab7ec 100644 ---- a/frankenphp.h -+++ b/frankenphp.h -@@ -7,38 +7,11 @@ - #define WIN32_LEAN_AND_MEAN - #endif - --// Explicitly include Winsock2 BEFORE windows.h -+#include - #include - #include - #include - #include -- --// Fix for missing IntSafe functions (LongLongAdd) when building with Clang --#ifdef __clang__ --#ifndef INTSAFE_E_ARITHMETIC_OVERFLOW --#define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L) --#endif -- --#ifndef LongLongAdd --static inline HRESULT LongLongAdd(LONGLONG llAugend, LONGLONG llAddend, -- LONGLONG *pllResult) { -- if (__builtin_add_overflow(llAugend, llAddend, pllResult)) { -- return INTSAFE_E_ARITHMETIC_OVERFLOW; -- } -- return S_OK; --} --#endif -- --#ifndef LongLongSub --static inline HRESULT LongLongSub(LONGLONG llMinuend, LONGLONG llSubtrahend, -- LONGLONG *pllResult) { -- if (__builtin_sub_overflow(llMinuend, llSubtrahend, pllResult)) { -- return INTSAFE_E_ARITHMETIC_OVERFLOW; -- } -- return S_OK; --} --#endif --#endif - #endif - - #include -diff --git a/internal/testcli/main.go b/internal/testcli/main.go -index c03c836c4d..8086f549e8 100644 ---- a/internal/testcli/main.go -+++ b/internal/testcli/main.go -@@ -13,9 +13,5 @@ func main() { - os.Exit(1) - } - -- if len(os.Args) == 3 && os.Args[1] == "-r" { -- os.Exit(frankenphp.ExecutePHPCode(os.Args[2])) -- } -- -- os.Exit(frankenphp.ExecuteScriptCLI(os.Args[1], os.Args)) -+ os.Exit(frankenphp.ExecuteScriptCLI(os.Args[0], os.Args)) - } -diff --git a/internal/testext/exttest.go b/internal/testext/exttest.go -index bbbe9bbd22..8e9f74cac8 100644 ---- a/internal/testext/exttest.go -+++ b/internal/testext/exttest.go -@@ -8,7 +8,7 @@ package testext - // #cgo unix LDFLAGS: -L/usr/local/lib -L/usr/lib -lphp -lm -lutil - // #cgo linux LDFLAGS: -ldl -lresolv - // #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -L/opt/homebrew/lib -L/opt/homebrew/opt/libiconv/lib -liconv -ldl --// #cgo windows CFLAGS: -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -D_MBCS -D_USE_MATH_DEFINES -DNDebug -DNDEBUG -DZEND_DEBUG=0 -DZTS=1 -DFD_SETSIZE=256 -+// #cgo windows CFLAGS: -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -D_MBCS -D_USE_MATH_DEFINES -DNDebug -DNDEBUG -DZEND_DEBUG=0 -DZTS=1 -DFD_SETSIZE=256 -DENABLE_INTSAFE_SIGNED_FUNCTIONS - // #include "extension.h" - import "C" - import ( diff --git a/src/hook/Frankenphp.php b/src/hook/Frankenphp.php deleted file mode 100644 index 7348c74..0000000 --- a/src/hook/Frankenphp.php +++ /dev/null @@ -1,78 +0,0 @@ -getSourceDir() . '/main/php_globals.h'); - if (preg_match('/^\s*(char|zend_string)\s*\*\s*output_handler;/m', $globals, $match) !== 1) { - throw new WrongUsageException('frankenphp: cannot determine the PG(output_handler) type from php_globals.h'); - } - if ($match[1] === 'char') { - return false; - } - - $file = $package->getSourceDir() . '/frankenphp.c'; - $source = FileSystem::readFile($file); - - if (str_contains($source, 'ZSTR_LEN(PG(output_handler))')) { - return false; - } - - if (!str_contains($source, self::OLD_OUTPUT_HANDLER)) { - throw new WrongUsageException("frankenphp: upstream frankenphp.c no longer matches the PHP 8.6 patch, missing:\n" . self::OLD_OUTPUT_HANDLER); - } - - FileSystem::writeFile($file, str_replace(self::OLD_OUTPUT_HANDLER, self::NEW_OUTPUT_HANDLER, $source)); - - return true; - } - - #[PatchBeforeBuild] - #[PatchDescription('Drop frankenphp\'s CLI emulation in favour of php-src do_php_cli() (php/frankenphp#1757)')] - public function patchCliBeforeBuild(TargetPackage $package): bool - { - return SourcePatcher::patchFile(dirname(__DIR__, 2) . '/config/patches/frankenphp-1757.patch', $package->getSourceDir()); - } -}