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
4 changes: 4 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func newWorkerDummyContext(w *worker) (*frankenPHPContext, error) {
}
}

if fc.requestURI == "" {
fc.requestURI = r.URL.RequestURI()
}

splitCgiPath(fc)

return fc, nil
Expand Down
14 changes: 14 additions & 0 deletions testdata/worker-boot-request-uri.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// mimics apps (e.g. Nextcloud) that exit during boot when REQUEST_URI is empty
if (($_SERVER['REQUEST_URI'] ?? null) === '') {
exit(1);
}

$bootRequestUri = $_SERVER['REQUEST_URI'];

require_once __DIR__.'/_executor.php';

return function () use ($bootRequestUri) {
echo $bootRequestUri;
};
13 changes: 13 additions & 0 deletions worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ func TestWorkerEnv(t *testing.T) {
}, &testOptions{workerScript: "worker-env.php", nbWorkers: 1, env: map[string]string{"FOO": "bar"}, nbParallelRequests: 10})
}

// https://github.com/php/frankenphp/issues/2697
func TestWorkerBootHasRequestURI(t *testing.T) {
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
req := httptest.NewRequest("GET", "http://example.com/worker-boot-request-uri.php", nil)
w := httptest.NewRecorder()
handler(w, req)

body, _ := io.ReadAll(w.Result().Body)

assert.Equal(t, "worker-boot-request-uri.php", string(body))
}, &testOptions{workerScript: "worker-boot-request-uri.php", nbWorkers: 1, nbParallelRequests: 1})
}

func TestWorkerGetOpt(t *testing.T) {
logger, buf := newTestLogger(t)

Expand Down
Loading