Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frankenphp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ func TestEnvWorker(t *testing.T) {
testEnv(t, &testOptions{workerScript: "test-env.php"})
}
func testEnv(t *testing.T, opts *testOptions) {
assert.NoError(t, os.Setenv("EMPTY", ""))

runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
req := httptest.NewRequest("GET", fmt.Sprintf("http://example.com/test-env.php?var=%d", i), nil)
w := httptest.NewRecorder()
Expand Down
7 changes: 6 additions & 1 deletion phpthread.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newPHPThread(threadIndex int) *phpThread {
}

// change the thread handler safely
// must be called from outside of the PHP thread
// must be called from outside the PHP thread
func (thread *phpThread) setHandler(handler threadHandler) {
logger.Debug("setHandler")
thread.handlerMu.Lock()
Expand Down Expand Up @@ -73,8 +73,13 @@ func (thread *phpThread) getActiveRequest() *http.Request {
// Pin a string that is not null-terminated
// PHP's zend_string may contain null-bytes
func (thread *phpThread) pinString(s string) *C.char {
if s == "" {
return nil
}

sData := unsafe.StringData(s)
thread.Pin(sData)

return (*C.char)(unsafe.Pointer(sData))
}

Expand Down
2 changes: 2 additions & 0 deletions testdata/test-env.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@
} else {
echo "Failed to unset NON_EXISTING_VAR.\n";
}

getenv();
};
Loading