PHP 4.0 Bug #6795 Updated: Problem with the value of $PATH_TRANSLATED
| From: | sniper@php.net | Date: | Tue, 16 Jan 2001 11:03:28 +0000 |
| Subject: | PHP 4.0 Bug #6795 Updated: Problem with the value of $PATH_TRANSLATED | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-44218@lists.php.net to get a copy of this message | ||
ID: 6795
Updated by: sniper
Reported By: drew@elysium.ltd.uk
Old-Status: Closed
Status: Open
Bug Type: Apache related
Assigned To:
Comments:
Reopened per user request. Problem still exists
with php4.0.4pl1
--Jani
Previous Comments:
---------------------------------------------------------------------------
[2000-12-30 14:05:49] sniper@php.net
No feedback, considered fixed.
--Jani
---------------------------------------------------------------------------
[2000-12-04 09:01:27] sniper@php.net
Could you please check if this problem exists when
using the PHP 4.0.4RC3:
http://www.php.net/distributions/php-4.0.4RC3.tar.gz
--Jani
---------------------------------------------------------------------------
[2000-09-17 19:49:16] drew@elysium.ltd.uk
There seems to be a problem with the values of $PATH_TRANSLATED under different circumstances :-
In your Apache document_root create the following files :-
.htaccess
AddHandler testhandler .test
Action testhandler handler.phtml
handler.phtml
<? print "PATH_TRANSLATED = $PATH_TRANSLATED"; ?>
index.test
Content not used
You will need AllowOverride All (or similar) in the Directory spec for your Apache document root (to
all adding handlers).
Here is a list of requests and responses
http://localhost/index.test -
PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)
http://localhost/handler.phtml -
PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct)
http://localhost/index.test/path_info -
PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)
http://localhost/handler.phtml/path_info -
PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)
The reason I have put incorrect for 3 of the tests is that the value differs from the value of
PATH_TRANSLATED that Apache provides. PHP just copies the value of SCRIPT_FILENAME over the top of
PATH_TRANSLATED. Please find attached a patch to make to responses the same as Apache's
version of PATH_TRANSLATED.
http://localhost/index.test -
PATH_TRANSLATED = /home/httpd/html/index.test (Correct)
http://localhost/handler.phtml -
PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct)
http://localhost/index.test/path_info -
PATH_TRANSLATED = /home/httpd/html/index.test/path_info (Correct)
http://localhost/handler.phtml/path_info -
PATH_TRANSLATED = /home/httpd/html/path_info (Incorrect)
Not really sure whats going on with the last test - bug in Apache. There is also a pretty big bug
in Apache when doing these type of tests from a public_html (~user) type of directory.
Rgds Drew Wells
--- php-4.0.2/sapi/apache/mod_php4.c.orig Sun Aug 20 15:29:00 2000
+++ php-4.0.2/sapi/apache/mod_php4.c Mon Sep 18 12:16:49 2000
@@ -232,7 +232,7 @@
register int i;
array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
table_entry *elts = (table_entry *) arr->elts;
- char *script_filename=NULL;
+ char *script_filename = NULL, *path_translated = NULL;
for (i = 0; i < arr->nelts; i++) {
char *val;
@@ -241,7 +241,10 @@
val = elts[i].val;
if (!strcmp(elts[i].key, "SCRIPT_FILENAME")) {
script_filename = val;
+ } else if (!strcmp(elts[i].key, "PATH_TRANSLATED")) {
+ path_translated = val;
}
+
} else {
val = empty_string;
}
@@ -249,7 +252,7 @@
}
/* insert special variables */
- if (script_filename) {
+ if (script_filename && !path_translated) {
php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array
ELS_CC PLS_CC);
}
php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri,
track_vars_array ELS_CC PLS_CC);
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6795