[php-src] PR #20649: add path info to slow log
| From: | fabiosal | Date: | Fri, 05 Dec 2025 15:47:45 +0000 |
| Subject: | [php-src] PR #20649: add path info to slow log | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34217@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20649
Author: fabiosal
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 https://github.com/php/php-src/issues/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 https://github.com/php/php-src/blob/4cc5f0238746704ae683676c0be4b97b7dbc9a11/sapi/fpm/fpm/fpm_main.c#L1334
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