Skip to content

Conversation

@fabiosal
Copy link

@fabiosal fabiosal commented Dec 5, 2025

Hi,
I was looking to add to slow logs information about request url. This is useful in case the web server is modifying the url as described here #18536

The sapi_request_info structure already foresee a request_uri variable,
but it is going to ends up containing the "SCRIPT FILENAME" after static void init_request_info(void) is executed

SG(request_info).request_uri = env_script_name;

so I added the path_info variable to the sapi_request_info, in order to put in it the value of the PATH_INFO parameter setted by the web server.

Then in the slow log the request_method, request_path_info and request_query_string are added

[05-Dec-2025 14:20:01]  [pool www] pid 167
script_filename = /var/www/public/index.php
request_method = GET
request_path_info = /lucky/number/4
request_query_string = ciao=hello
[0x00007ffff6215070] sleep() /var/www/public/index.php:3

In order to work properly the web server should add the PATH_INFO to the request to fpm

ie for nginx

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$uri$is_args$args;
    }
    
    ....
     location ~ ^/index\.php(/|$) {
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            ...
     }
    ..

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant