mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
fix: opcache_preload in PHP 8.2 (#2284)
Fixes the Docker image tests currently failing in CI.
This commit is contained in:
committed by
GitHub
parent
097563d262
commit
9cfa7b3f65
@@ -1227,7 +1227,7 @@ int frankenphp_execute_script(char *file_name) {
|
|||||||
|
|
||||||
zend_destroy_file_handle(&file_handle);
|
zend_destroy_file_handle(&file_handle);
|
||||||
|
|
||||||
/* Reset the sandboxed environment */
|
/* Reset the sandboxed environment if it is in use */
|
||||||
if (sandboxed_env != NULL) {
|
if (sandboxed_env != NULL) {
|
||||||
zend_hash_release(sandboxed_env);
|
zend_hash_release(sandboxed_env);
|
||||||
sandboxed_env = NULL;
|
sandboxed_env = NULL;
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ func TestMain(m *testing.M) {
|
|||||||
slog.SetDefault(slog.New(slog.DiscardHandler))
|
slog.SetDefault(slog.New(slog.DiscardHandler))
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup custom environment var for TestWorkerHasOSEnvironmentVariableInSERVER
|
// setup custom environment var for TestWorkerHasOSEnvironmentVariableInSERVER and TestPhpIni
|
||||||
if os.Setenv("CUSTOM_OS_ENV_VARIABLE", "custom_env_variable_value") != nil {
|
if os.Setenv("CUSTOM_OS_ENV_VARIABLE", "custom_env_variable_value") != nil || os.Setenv("LITERAL_ZERO", "0") != nil {
|
||||||
fmt.Println("Failed to set environment variable for tests")
|
fmt.Println("Failed to set environment variable for tests")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@@ -162,14 +162,12 @@ func testHelloWorld(t *testing.T, opts *testOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEnvVarsInPhpIni(t *testing.T) {
|
func TestEnvVarsInPhpIni(t *testing.T) {
|
||||||
t.Setenv("OPCACHE_ENABLE", "0")
|
|
||||||
|
|
||||||
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, _ int) {
|
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, _ int) {
|
||||||
body, _ := testGet("http://example.com/ini.php?key=opcache.enable", handler, t)
|
body, _ := testGet("http://example.com/ini.php?key=opcache.enable", handler, t)
|
||||||
assert.Equal(t, "opcache.enable:0", body)
|
assert.Equal(t, "opcache.enable:0", body)
|
||||||
}, &testOptions{
|
}, &testOptions{
|
||||||
phpIni: map[string]string{
|
phpIni: map[string]string{
|
||||||
"opcache.enable": "${OPCACHE_ENABLE}",
|
"opcache.enable": "${LITERAL_ZERO}",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1305,20 +1303,26 @@ func TestSessionNoLeakAfterExit_worker(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOpcachePreload_module(t *testing.T) {
|
func TestOpcachePreload_module(t *testing.T) {
|
||||||
testOpcachePreload(t, &testOptions{env: map[string]string{"TEST": "123"}})
|
testOpcachePreload(t, &testOptions{env: map[string]string{"TEST": "123"}, realServer: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOpcachePreload_worker(t *testing.T) {
|
func TestOpcachePreload_worker(t *testing.T) {
|
||||||
testOpcachePreload(t, &testOptions{workerScript: "preload-check.php", nbWorkers: 1, nbParallelRequests: 1, env: map[string]string{"TEST": "123"}})
|
testOpcachePreload(t, &testOptions{workerScript: "preload-check.php", env: map[string]string{"TEST": "123"}, realServer: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testOpcachePreload(t *testing.T, opts *testOptions) {
|
func testOpcachePreload(t *testing.T, opts *testOptions) {
|
||||||
|
if frankenphp.Version().VersionID <= 80300 {
|
||||||
|
t.Skip("This test is only supported in PHP 8.3 and above")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
preloadScript := cwd + "/testdata/preload.php"
|
preloadScript := cwd + "/testdata/preload.php"
|
||||||
|
|
||||||
u, err := user.Current()
|
u, err := user.Current()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// use opcache.log_verbosity_level:4 for debugging
|
||||||
opts.phpIni = map[string]string{
|
opts.phpIni = map[string]string{
|
||||||
"opcache.enable": "1",
|
"opcache.enable": "1",
|
||||||
"opcache.preload": preloadScript,
|
"opcache.preload": preloadScript,
|
||||||
|
|||||||
Reference in New Issue
Block a user